Saturday, November 16, 2024
HomeUNIXDecompress and extract a tgz or tar.gz archive in a single step

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

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 -

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!