Objective: Gunzip, by default will delete the .gz
file after decompression. Learn how to retain the original files after extracting the .gz
file.
The first method to keep the original .gz
files is to use the -c
option of gunzip. The -c
option will write the decompressed data to stdout
and will not remove the original .gz
file. To extract the file foo.gz
to foo
while keeping the foo.gz
file, use the following syntax.
1 2 3 4 5 6 |
$ gunzip -c foo.gz > foo ls -l total 2808 -rw-r--r-- 1 root root 2150400 Aug 7 15:10 foo -rw-r--r-- 1 root root 724005 Aug 7 15:09 foo.gz |
The output of gunzip
is redirected to the decompressed file called foo
.
The other method is to use zcat
instead of gunzip -c
.
1 |
$ zcat foo.gz > foo |
If the gzcat
utility is not available on your system, try using zcat
instead.