How can I write data to stdout instead of writing file?
I'm using GPG and want to print encrypted text to stdout, without saving files.
However, with gpg command, encrypted text is written to file in ordinary way:
$> gpg --recipient [email protected] --armor --output encrypted.txt --encrypt example.pdf
(With above command, encrypted file is saved in encrypted.txt)
What I want to do is like following:
$> gpg --recipient [email protected] --armor --output <STDOUT> --encrypt example.pdf
and encrypted messages are shown in console.
I don't want to save hard disk to avoid loss of performance.
Usually you use "-" to specify stdout, but not all commands accept this and I don't about gpg.
For example:
tar -cvzf - foo/ ¦ split -b 50k foobar_
will pipe the "tar-file" to stdout, split it and save to "foobar_<123...>".
If your application does not support '-' as a filename (and it should) then an alternative is to use a named pipe, although I'll admit this looks like using a sledgehammer to crack a nut:
pipe='/tmp/pipe'
mkfifo "$pipe"
gpg --recipient [email protected] --armor --output "$pipe" --encrypt example.pdf &
while read
do
echo "$REPLY"
done < $pipe
rm "$pipe"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With