|
CEG 333: Introduction to UnixPrabhaker Mateti
|
Tar stands for "tape archiver", although tar files
are more commonly found on Internet sites than tapes nowadays. It
is the most common Unix archiving utility. Unlike some compression
utilities (like pkzip for .zip files), tar can only
archive files (combine them into one large file) and not compress
them. In keeping with the Unix philosophy of small programs that
are combined as needed, separate compressors are used in
conjunction with tar.
Tar can automatically call a compressor for seamless
compression and decompression of archives. There are three
different major Unix compressors: compress,
gzip, and bzip2 Each of these works with
single files. Alone, they can't combine multiple files into one
package.
A tar command line gives:
-x for extract-t for list-c for create.-Z for compress (.Z files)-z for gzip (.gz files)-j for bzip2 (.bz2 files)-v to list every
file tar operates on, -vv to provide a complete
listing (like ls -l)-f followed by the name of the archive
file. (If absent, tar operates on stdin/out)For example, the tar xvvfj ~/P1-2003-Fall.tbz
command given in
P3 means: "Extract this is a tar file compressed with
bzip2, listing every file as it's extracted."
WARNING: The file option ("-f" or just
"f") uses the string immediately after it as the
output filename! So tar -czfv output.tar input files
will fail, because tar will write its output to a file named
"v" and give an error when it doesn't find an input file
named "output.tar".