How to remove warnings from “keytool” command in bash

Viewed 3291

How can I remove the warning from the output of

keytool -v -alias sssa -list -keystore /var/tmp/certs -storepass passwd | grep 'until' | head -1 | grep -v Warning

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /opt/miep/msaapp/msa_domain/.keystore -destkeystore /opt/miep/msaapp/msa_domain/.keystore -deststoretype pkcs12".

Valid from: Wed Feb 12 19:00:00 EST 2020 until: Sat Feb 13 07:00:00 EST 2021

I need only the last line.

2 Answers

Warnings and errors are usually printed to STDERR rather than STDOUT, add a STDERR redirect to get rid of them:

keytool -v -alias sssa -list -keystore /var/tmp/certs -storepass passwd 2>/dev/null | ...

Related