Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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'
share|improve this answer
    
Thanks a lot. It works! –  revher Jul 18 '13 at 16:40
    
@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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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