How do you gunzip a file and keep the .gz file?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Track title: CC O Beethoven - Piano Sonata No 3 in C
--
Chapters
00:00 Question
00:33 Accepted answer (Score 288)
01:05 Answer 2 (Score 68)
01:27 Answer 3 (Score 43)
01:41 Answer 4 (Score 17)
01:57 Thank you
--
Full question
https://superuser.com/questions/45650/ho...
Answer 1 links:
[manual page]: http://www.freebsd.org/cgi/man.cgi?quer
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #gunzip #gz
#avk47
--
Track title: CC O Beethoven - Piano Sonata No 3 in C
--
Chapters
00:00 Question
00:33 Accepted answer (Score 288)
01:05 Answer 2 (Score 68)
01:27 Answer 3 (Score 43)
01:41 Answer 4 (Score 17)
01:57 Thank you
--
Full question
https://superuser.com/questions/45650/ho...
Answer 1 links:
[manual page]: http://www.freebsd.org/cgi/man.cgi?quer
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #gunzip #gz
#avk47
ACCEPTED ANSWER
Score 296
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
ANSWER 2
Score 69
You can use the -c
option of gunzip which writes the output to stdout, and then pipe it to the file of your choice:
gunzip -c compressed-file.gz > decompressed-file
More details on the manual page.
ANSWER 3
Score 46
A simpler solution is to just use gunzip as a filter like this:
gunzip < myfile.gz > myfile
ANSWER 4
Score 14
If it's actually a tarball (.tgz or .tar.gz extension), then instead of redirecting to file like all of the answers so far, you'll want to pipe it to tar, like so:
gunzip -c myfile.tar.gz | tar xvf -
so that you get the actual contents.