Go to the previous, next section.
(This message will disappear, once this node revised.)
This example shows you how to create an archive file in your working
directory containing other files in the same directory. The three
files you archive in this example are called `blues',
`folk', and `jazz'. The archive file is called
`records'. While the archive in this example is written to the
file system, it could also be written to tape. (If you want to follow
along with this and future examples, create a practice subdirectory
containing files with these names. To create the directory, type
`mkdir practice' at the system prompt. You can create the files
using a text editor, such as emacs
).
While in the directory containing the files you want to archive, list the directory's contents.
Type:
% cd practice % ls
The system responds:
blues folk jazz %
This is to check that the files to be archived do in fact exist in the
working directory, and to check that the archive name you have chosen
isn't already in use. If it is, tar
will overwrite the old
archive and its contents will be lost.
Then,
tar
.
tar
will write the archive to
the default storage device, which varies from system to system.
tar
will archive everything in the
working directory.
Type:
% tar --create --file=records blues folk jazz
If you now list the contents of the working directory (`ls'), you will find the archive file listed as well as the files you saw previously.
% ls blues folk jazz records %
This example shows you how to create an archive file in the working directory containing other files in the working directory. The three files you archive in this example are called `blues', `folk', and `jazz'. The archive file is called `records'. While the archive in this example is written to the file system, it could also be written to any other device.
(If you want to follow along with this and future examples, create a directory called `practice' containing files called `blues', `folk' and `jazz'. To create the directory, type `mkdir practice' at the system prompt. It will probably be easiest to create the files using a text editor, such as Emacs.)
First, change into the directory containing the files you want to archive:
% cd practice
`~/practice' is now your working directory.
Then, check that the files to be archived do in fact exist in the
working directory, and make sure there isn't already a file in the
working directory with the archive name you intend to use. If you
specify an archive file name that is already in use, tar
will
overwrite the old file and its contents will be lost.
To list the names of files in the working directory, type:
% ls
The system responds:
blues folk jazz %
Then,
tar
.
tar
will write the archive to the default
storage device, which varies from system to system.
FIXME: this syntax may change. OK now--check before printing
tar
interprets archive file names relative to the working
directory. Make sure you have write access to the working
directory before using tar
.
tar
interprets
file names relative to the working directory). If you don't use
any name arguments, tar
will archive everything in the
working directory.
Type:
% tar --create --file=records blues folk jazz
If you now list the contents of the working directory (`ls'), you will find the archive file listed as well as the files you saw previously.
% ls blues folk jazz records %
Go to the previous, next section.