Tuesday 9 February 2010

How to extract / unzip a .tar.gz file into a different directory

What happens if you need to extract a .tar.gz file, but don't have enough free disk space in the directory? It might show you an error like this:

tar: Wrote only 9216 of 10240 bytes
tar: Skipping to next header
tar: Error exit delayed from previous errors


Tar and Gunzip will only extract into the current directory. Here is a command that will unzip a .tar.gz archive into a new directory.

cd /new-directory
gzip -dc /path/file.tar.gz|tar xvf --

No comments: