Home » Questions » Computers [ Ask a new question ]

How do you gunzip a file and keep the .gz file?

How do you gunzip a file and keep the .gz file?

The default behavior of gunzip is to delete the .gz file after it decompresses.

Asked by: Guest | Views: 246
Total answers/comments: 4
bert [Entry]

"You're looking for:

gzcat x.txt.gz >x.txt

The gzcat command is equivalent to gunzip -c which simply writes the output stream to stdout. This will leave the compressed file untouched. So you can also use:

gunzip -c x.txt.gz >x.txt

Note that on some systems gzcat is also known as zcat so run like this instead:

zcat x.txt.gz >x.txt"
bert [Entry]

"A simpler solution is to just use gunzip as a filter like this:

gunzip < myfile.gz > myfile"
bert [Entry]

"Use the -c option to uncompress the file to stdout. It will not touch the original file.

gunzip -c myfile.gz > myfile"
"Use the -c option to uncompress the file to stdout. It will not touch the original file.

gunzip -c myfile.gz > myfile"
bert [Entry]

Gnu tar can read gzip files: tar -zxsvf myfile.tar.gz or tar -jxzvf myfile.tar.bz2 for bzipped tar files.