Extract files from a .tar.gz file
From Computing and Software Wiki
('''Extract files from a .tar.gz file) |
|||
Line 1: | Line 1: | ||
'''Extract files from a .tar.gz file ''' | '''Extract files from a .tar.gz file ''' | ||
- | A .tar.gz file that contains a bundle of files packaged by tar utility and then compressed by gzip program, therefore basically two steps are required to restore such a file: | + | A .tar.gz file that contains a bundle of files [packaged by tar utility] and then compressed by gzip program, therefore basically two steps are required to restore such a file: |
1) uncompress it use gzip of gunzip: | 1) uncompress it use gzip of gunzip: |
Revision as of 16:26, 9 April 2007
Extract files from a .tar.gz file
A .tar.gz file that contains a bundle of files [packaged by tar utility] and then compressed by gzip program, therefore basically two steps are required to restore such a file:
1) uncompress it use gzip of gunzip:
gzip -d File_Name.tar.gz or gunzip File_Name.tar..gz This will make the file File_Name.tar.gz replaced by a uncompressed File_Name.tar file.
2) Unpackage the .tar file:
tar -xvf File_Name.tar You can combine the two steps together by:
gzip -dc File_Name.tar.gz | tar -xvf - or gunzip -c File_Name.tar.gz | tar -xvf - (The "-" after the "tar -xvf" is to tell tar to read from the standard input.)
Our Solaris system has a gtar program available. With gtar, users can specify a -z option to tell gtar to zip or unzip the target file thus makes it possible to handle a .tar.gz file truely in a single step:
To create a .tar.gz file using gtar:
gtar -czvf File_Name.tar.gz File1 File2 File3 ... This will pack File1, File2, File3 and other files on the list and compress them to create a File_Name.tar.gz file. To extract files from a .tar.gz file: .
gtar -xzvf File_Name.tar.gz This will uncompress and unpack File_Name.tar.gz