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: 79
Total answers/comments: 4
Guest [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"
Guest [Entry]

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

gunzip < myfile.gz > myfile"
Guest [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"
Guest [Entry]

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