How to use pv to show progress of openssl encryption / decryption?
You should try
openssl enc -aes-256-cbc -d -salt -in "$input_filename" | pv -W >> "$output_filename"
From the Manual:
-W, --wait:
Wait until the first byte has been transferred before showing any progress information or calculating any ETAs. Useful if the program you are piping to or from requires extra information before it starts, eg piping data into gpg(1) or mcrypt(1) which require a passphrase before data can be processed.
which is exactly your case. If you need to see the progress bar, for the reason clearly explained by Weijun Zhou in a comment below, you can reverse the order of the commands in the pipe:
pv -W "$input_filename" | openssl enc -aes-256-cbc -d -salt -out "$output_filename"
You need named pipe here.
$ mkfifo mypipe
$ pv < mypipe > "$output_filename"|(pv "$input_filename" | openssl enc -aes-256-cbc -d -salt -out mypipe)
The output of the two pv
commands will show alternately at the bottom of your tty window. Not sure whether it is what you really need, though. If you only need the output of the pv
in pv "$input_filename"
, modify the above command accordingly.
Edit
After obtaining more information from the OP, I am now sure that
pv "$input_filename" | openssl enc -aes-256-cbc -d -salt -out "$output_filename"
is enough to address OP's real needs.