Showing posts with label tar. Show all posts
Showing posts with label tar. Show all posts

Monday, 11 August 2008

Extract a specific file from tar archive

If gzipped, first run gunzip {filename}.tar.gz Then...

tar --extract --file={filename}.tar {file(s) to extract}

HOW TO: list files within a gzipped tar

tar -tzf file.tar.gz

-t: lists files
-f: instructs tar to deal with the following filename (file.tar.gz)
-z: informs tar that the it's dealing with a gzip file (-j if it's bzip2)

Tuesday, 30 October 2007

How to compress and decompress tar and gzip files

How to untar a file

A lot of Linux/Unix files you find yourself working with will be compressed using tar and/or gzip. These are files with extensions like .tar and .tar.gz.

Extracting

For.tgz, tar.gz, or tar.z extension use this command:

tar -zxvf {filename}

Eg: tar -zxvf filename.tar.gz

This will extract the file for you in the directory you are currently in. Using the above command will save you from having to redirect the output for gzip or anything else (because the z option automatically decompresses the file for you), otherwise without the z argument, you would have to do the extraction for the gzip first, then do a tar -xvf for the tar archive.


Archiving

To create a gzipped .tar file, use the following command...

tar -cf {filename}

...to create filename.tar
Eg: tar -cf filename

- Then -

gzip {filename.tar}

...to create filename.tar.gz