Live Chat Software by Kayako
Knowledgebase: General
How to: Tar Files
Posted by Ahman donk on 21 April 2008 04:27 AM
Tar Notes
tar stands for tape archive and can be used to make a big file filled with many smaller files which can then be easily transported across directories, mahcines or networks.

Usage / Syntax
command [-options] /location/of/new/file.tar /files/to/archive

tar -cvf /scratch/myfile_20030617.tar /scratch/mydir/results/stat/*

Popular options and their significance

-c = create
-f = read to/from the named file (instead of the device /tape)
-t = list contents of .tar file
-r = append to a .tar file
-v = verbose (tells you everything its doing)
-x = extract contents of .tar file
-z = compress files (not so useful for minc files)

To extract files from your file
tar -xf myfile_20030617.tar

Note that a path name beginning with a forward slash is an absolute path name, e.g.: /scratch/mydir whereas a path name with no forward slash at the beginning is a relative path name. Thus, if you are in directory /scratch/mydir and want to tar a bunch of files in /scratch/mydir/subdir, you may use relative path names, eg:

tar -cf /scratch/myfile_blah.tar subdir/*

To select files for the tar file using find
tar -cvf ps.tar `find /path/name/here -name '*.ps*' -print` gzip ps.tar

Be diligent with use of backquotes (`) and forward quotes (')!

To move tar file from one location to another

scp [email protected]:/destination/myfile.tar /local/path/
(115 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Kayako