I have a file file.gz
, when I try to unzip this file by using gunzip file.gz
, it unzipped the file but only contains extracted and removes the file.gz
file.
How can I unzip by keeping both unzipped file and zipped file?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHere are several alternatives:
Give gunzip
the --keep
option (version 1.6 or later)
-k
--keep
Keep (don't delete) input files during compression or decompression.
gunzip -k file.gz
Pass the file to gunzip
as stdin
gunzip < file.gz > file
Use zcat
(or, on older systems, gzcat
)
zcat file.gz > file
gunzip
with -k
or --keep
? I'm using version 1.5 in Gentoo and it has no such option.
Sep 18, 2014 at 22:02
--keep
but don't have it, just make a copy of file.gz
first.
gunzip -c file.gz > file
or zcat file.gz > file
also work. superuser.com/questions/45650/…
Without requiring a temporary file:
zcat somefile.gz > somefile
zcat file.sql.gz | mysql --max_allowed_packet=32M db