I would like to decrypt several gpg encrypted files in one single stream to be piped to another command without any temporary file. $ cat foo1.txt.gpg foo2.txt.gpg | gpg -d | wc -l will count only the lines of foo1, not including foo2.

The --decrypt-files option is able to decrypt multiple files but doesn't seem to be able to pipe all decrypted files on a single stdout: $ gpg --decrypt-files foo*.txt.gpg | wc -l (will output 0 )

Any hint is welcome


I guess you should use multiple gpg invocations in a loop:

{ for i in foo1.txt.gpg foo2.txt.gpg; do gpg -d < $i; done; } | wc -l

The multiple gpg invocations will ask for your password multiple times unless you use gpg agent or similar:

gpg-agent --daemon sh -c \
'{ for i in foo1.txt.gpg foo2.txt.gpg; do gpg -d < $i; done; } | wc -l'
| improve this answer | |
  • @revher: Glad to head that. Feel free to accept this answer to indicate this fact. You can still change your check mark later on if some better answer should come up. – MvG Jul 18 '13 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.