Decompress gzip file to specific directory [closed]

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)