next up previous

3.1.4 Text Compression and File Archives     continued...


(just a set of three files)

% mkdir letters
(make a new directory for these files)

% cd letters
% tar xvf ../letters.tar
(extract files in the new directory)

x alpha, 6 bytes, 1 media blocks.
x beta, 5 bytes, 1 media blocks.
x gamma, 6 bytes, 1 media blocks.
% cd ..
% ls -F
foo/ letters/
ls letters
alpha beta gamma
% ls foo
bar baz foo

The easiest way to create an archive is to collect all the information in a single directory and then archive the entire directory. For example, suppose you have collected everything you want to save (simple files and other directories) in a directory named oldstuff. The following command will make an archive named oldstuff.tar:

tar  cvf  oldstuff.tar  oldstuff
Building a new archive can be tricky. A common mistake is to put the new archive in the directory you are trying to save. For example this command tells tar to collect everything in the current directory (named `.' in Unix) and put it in oldstuff.tar:

tar cvf oldstuff.tar .

(aaargggh! don't do this)