gpg decrypting multiple files in one stream

3

1

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

revher

Posted 2013-07-18T11:23:17.490

Reputation: 71

Answers

3

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'

MvG

Posted 2013-07-18T11:23:17.490

Reputation: 1 259

@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 – 2013-07-18T16:42:19.110