Take the following command (real example) :
~$ gpg --edit-key [email protected] showpref quit
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
Piping the output into a | grep doesn't work :
~$ gpg --edit-key [email protected] showpref quit | grep Compression
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
Is there a way to make that work ? E.g., the result I'd like to get is :
~$ gpg --edit-key [email protected] showpref quit | grep Compression
Compression: ZLIB, BZIP2, ZIP, Uncompressed
~$
[EDIT : what I tried so far ] :
@steeldriver, @RomeoNinov : I don't think redirecting stderr is going to do the trick. It doesn't look like gpg's output goes to stderr.
Basically, gpg is an interactive command, but launching gpg ... cmd1 cmd2 makes it non-interactive (e.g., gpg ... showpref quit is the same as doing interactively showpref followed by quit in gpg's shell).
@steeldriver :
~$ gpg --edit-key [email protected] showpref quit 2> >(grep Compression)
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
@RomeoNinov :
~$ gpg --edit-key [email protected] showpref quit 2>&1| grep Compression
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
gpg --edit-key [email protected] showpref quit 2>&1| grep Compression?gpg's output goes to stderr.