Friday, January 15, 2010

use gunzip to uncompress a file to a different location


Here is how:

gunzip -c myfile.gz > newdir/mynewfile

More info:

If you use gunzip to uncompress a file, it will by default replace the old .gz file with a new uncompressed version of the original file name. If you want to rename or move the file, this may be an issue. For me, I wanted to uncompress a file that is on an external hard drive and store the uncompressed version on a different external hard drive. The -c option sends output to stdout and does not remove the original .gz file. Then, the uncompressed data is piped to file with the > part of the command.
[Image by Hayv Kahraman, from A Journey Round My Skull]

No comments: