What is the gzip equivalent of the following command:
tar xvzf /usr/local/file/file/file.tar.gz -C /usr/local/extract_here
I am trying
gzip -d /usr/local/file/file/file.tar.gz -C /usr/local/extract_here
but it does not work, how do I do that with gzip?
Just use zcat to see content without extraction. From the manual: zcat is identical to gunzip -c . (On some systems, zcat may be installed as gzcat to preserve the original link to compress .)
If you want to place it somewhere specific, create the directory ( mkdir /BIG5 ) and then extract the files into a file in there ( gunzip -c BIG5. gz > /BIG5/yourfile ). Related info: The > writes the output of a command into a file, never to a directory. So whatever is right of > will be a file.
You can unzip GZ files in Linux by adding the -d flag to the Gzip/Gunzip command. All the same flags we used above can be applied. The GZ file will be removed by default after we uncompressed it unless we use the -k flag. Below we will unzip the GZ files we compressed in the same directory.
Given the fact that you have a .tar.gz file, the first way you tried, with the -C option, will work just fine:
tar xvzf /dir/to/file.tar.gz -C /dir/to/output/
tar
calls gzip to decompress, and then extracts the files from the tar stream. gzip
can only decompress, so gunzip file.tar.gz
would simply leave with the decompressed file.tar
, on which you would then need to tar xvf file.tar
. The z
option of tar
is simply a shortcut to do the decompression with gzip along with extracting the files.
If you want to just decompress a .gz file (as opposed to extracting a .tar.gz file) to a different directory, simply pipe there. E.g. gzip -dc < file.gz > /somewhere/file
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With