Portal Home > Knowledgebase > General > How to: Tar Files


How to: Tar Files




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

Example
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 me@ipaddress:/destination/myfile.tar /local/path/

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
php exec (Views: 1322)
Webmin (Views: 1282)
My Website is Down! (Views: 1559)