Decompress and extract a tgz or tar.gz archive in a single step

Home -> UNIX

45463 views

From the computer of: qmchenry (339 recipes)
Created: Sep 15, 2003     Updated: Jul 12, 2006


0 comments:
View all comments

Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

Compressed UNIX tar archives (typically tar.gz or .tgz extensions) can be extracted in a single command. This is faster and works with less disk space available.

To extract the compressed tar archive target.tar.gz into the current working directory with:

gzip -dc target.tar.gz | tar xf -


If the file was compressed with bzip2 (i.e., .tar.bz2), you can substitute the bzip2 command for gzip.

If the archive was compressed with the UNIX compress command (archive ending in .Z) you can use:

zcat target.tar.Z | tar xf -

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  Extract a tar archive or file
  Extract a bz2 or bzip2 file
  Tar and compress a file in one step
  Create a TAR archive of a directory
  Extract a gzip compressed tar archive in Linux
  Select an arbitrary column of text in UNIX
  Validate information from a Solaris flash archive
  Create a local Solaris flash archive
  Create a symbolic link in UNIX
  Install patches manually in Solaris

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.