Search code examples
linuxterminalgnupg

Preventing GPG logs from being mixed with output in terminal when using "-o -"


I've used GPG to encrypt string directly from terminal to file like this:

echo "Hello World!" | gpg -c --batch --passphrase SomePassword > some_filename

Now I'm trying to decrypt the file and to output the content in the terminal like this:

gpg --batch -o - --passphrase SomePassword some_filename

It works but the output starts with this two lines:

gpg: AES encrypted data
gpg: encrypted with 1 passphrase

NOTE:

The file does not contain this lines (so it's GPG output).

The version of GPG is 1.4.20


Solution

  • AFAIK, GnuPG outputs its messages to stderr, so You can eliminate them by redirecting stderr to /dev/null:

    gpg -d --batch -o - --passphrase SomePassword some_filename 2> /dev/null