Encrypting to standard output with gnupg
I'm trying to encrypt something with gpg -a
and return the result to standard out rather than a file. According to the manual, it should be sufficient to omit an --output
flag, but that doesn't seem to be the case. When I don't specify an output file, gnupg assumes I'm outputting to [input-file].gpg
rather than stdout.
Is there a way to have GPG do this, or am I going to have to have it encrypt to a temporary file and then cat
it?
Instead of passing the input file to gpg, use shell redirection to send the input file to gpg's stdin, e.g.:
gpg -ac < inputfile
Just in case anyone still needs to do this, you can do it with
gpg -ac -o- infile
Setting the output filename to "-" sends the output to stdout.
If anybody else needs a better or more concise answer:
You can do gpg --output -
with any other flags.
For the example above you can do gpg --armor --symmetric --output - file.txt
or gpg -aco - file.txt