I want to get rid of two first lines generated after the usage of gpg -d file.txt.gpg, meaning that only text itself would be left. I tied to use --no-comment, but it seems to not work.

gpg: encrypted with 2048-bit RSA key, ID 4FXXXXXXXXD30D52, created 2020-01-22
      "test test <[email protected]>"

2 Answers 2

gpg --quiet -d file.txt.gpg 

(or -q)


In order to skip the first two lines of the output of a command, you can pipe it through awk and instruct it to ignore the first two lines:

~$ <whatever command> | awk 'NR<3 {next} {print}'

This will instruct awk to skip execution (next) of the line as long as awk's internal line counter (NR) is smaller than 3, but otherwise print the whole input line unchanged.


Note that since these two first lines seem to be written to stderr instead of stdout (as per @dave_thompson_085's comment), it is easier to either use @Anonymous' solution with the -q flag, or simply redirect stderr to /dev/null or an error file, as in

gpg -d file.txt.gpg 2>error.log
  • 1
    gpg writes those two lines to stderr not stdout, so this doesn't work unless you use 2>&1 | or on shells that support it |& Jan 25, 2020 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .