I want to write a bash script to decompress a file without overwriting the original one and redirect the operation result into a log file.
I found an answer to the first part of my question at: How to tell gzip to keep original file?
But I cannot report it into a log.
I've tried:
gzip -dfv < file.txt.gz > file.txt 2>&1 | tee -a log.txt
But it does not redirect operation output to log.txt file.
How can I do that?
Thank you all.
Note: I am working on a Virtual Machine which runs Ubuntu 10.04
and the installed gzip 1.3.12
does not offer the --keep
option. I should avoid updating any package in my system, because it is under strict configuration control and all updates are disabled due to security policies.
--keep
option? See the second answer. With that it's trivial; just redirect standard output and error in the usual way. – Faheem Mitha Apr 27 '16 at 22:17--keep
option. – Alfredo Capobianchi Apr 29 '16 at 14:44< file.gz
, that is stdin. What exactly do you expect-v
to print out in that case ? – don_crissti Apr 29 '16 at 14:53-v
as per the man page:display the name and percentage reduction for each file...
So when you use<file
the input is stdin not a file (or more files) so how do you expect it to work ? – don_crissti Apr 30 '16 at 17:51gzip
to report the name and percentage reduction for each file I passed to it, even with<file
... I guess this won't happen, since the input is stdin. I solved my problem by extracting the file and making a copy of it, since, in this way, I can report each operation into a log file. – Alfredo Capobianchi May 02 '16 at 15:37