To follow along with this and future examples, create a new directory called `practice' containing files called `blues', `folk' and `jazz'. The files can contain any information you like: ideally, they should contain information which relates to their names, and be of different lengths. Our examples assume that `practice' is a subdirectory of your home directory.
Now cd
to the directory named `practice'; `practice'
is now your working directory. (Please note: Although
the full path name of this directory is
`/homedir/practice', in our examples we will refer to
this directory as `practice'; the homedir is presumed.
In general, you should check that the files to be archived exist where
you think they do (in the working directory) by running ls
.
Because you just created the directory and the files and have changed to
that directory, you probably don't need to do that this time.
It is very important to make sure there isn't already a file in the
working directory with the archive name you intend to use (in this case,
`collection.tar'), or that you don't care about its contents.
Whenever you use `create', tar
will erase the current
contents of the file named by --file=archive-name (-f archive-name) if it exists. tar
will not tell you if you are about to overwrite a file unless you
specify an option which does this @FIXME{xref to the node for
--backup!}. To add files to an existing archive, you need to use a
different option, such as --append (-r); see section How to Add Files to Existing Archives: --append
for
information on how to do this.
Go to the first, previous, next, last section, table of contents.