[Next] [Previous] [Up] [Top] [Contents]

8.2 File Archiving, Compression and Conversion

8.2.2 tar - archive files

The tar command combines files into one device or filename for archiving purposes. The tar command does not compress the files; it merely makes a large quantity of files more manageable.


tar [options] [directory file]

Common Options

c create an archive (begin writting at the start of the file)

t table of contents list

x extract from an archive

v verbose

f archive file name

b archive block size

tar will accept its options either with or without a preceding hyphen (-). The archive file can be a disk file, a tape device, or standard input/output. The latter are represented by a hyphen.


Given the files and size indications below:

45 logs.beauty

89 logs.bottom

74 logs.photon

84 logs.top

tar can combine these into one file, logfile.tar:

% tar -cf logfile.tar logs.* ; ls -s logfile.tar

304 logfile.tar

Many anonymous FTP archive sites on the Internet store their packages in compressed tar format, so the files will end in .tar.Z or .tar.gz. To extract the files from these files you would first uncompress them, or use the appropriate zcat command and pipe the output into tar, e.g.:

% zcat archive.tar.Z | tar -xvf -

where the hyphen at the end of the tar command indicates that the file is taken from stdin.

Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]