Go to the previous, next section.
(This message will disappear, once this node revised.)
To create a new archive, use the `--create' (`-c') option to tar
.
You can use options to specify the name and format of the archive (as
well as other characteristics), and you can use file name arguments
to specify which files and directories are to be put in the archive.
FIXME: xref Creating, for more information about the `--create' (`-c') operation.
To create a new archive, use the `--create' (`-c') option to tar
.
You should generally use the `--file=archive-name' (`-f archive-name') option to specify the name
the tar
archive will have. Then specify the names of the
files you wish to place in the new archive. For example, to place
the files `apple', `angst', and `asparagus' into an
archive named `afiles.tar', use the following command:
tar --create --file=afiles.tar apple angst asparagus
The order of the arguments is not important when using mnemonic option style. You could also say:
tar apple --create angst --file=afiles.tar asparagus
This order is harder to understand however. In this manual, we will list the arguments in a reasonable order to make the commands easier to understand, but you can type them in any order you wish.
If you don't specify the names of any files to put in the archive,
then tar
will create an empty archive. So, the following
command will create an archive with nothing in it:
tar --create --file=empty-archive.tar
Whenever you use `--create' (`-c'), tar
will erase the current
contents of the file named by `--file=archive-name' (`-f archive-name') if it exists. To add files
to an existing archive, you need to use a different option.
FIXME: xref Adding to Archives, for information on how to do this.
When an archive is created through `--create' (`-c'), the member names of the
members of the archive are exactly the same as the file names as you
typed them in the tar
command. So, the member names of
`afiles' (as created by the first example above) are `apple',
`angst', and `asparagus'. However, suppose an archive were
created with this command:
tar --create --file=bfiles.tar ./balloons baboon ./bodacious
Then, the three files `balloons', `baboon', and `bodacious' would get placed in the archive (because `./' is a synonym for the current directory), but their member names would be `./balloons', `baboon', and `./bodacious'.
If you want to see the progress of tar
as it writes files into the
archive, you can use the `--verbose' (`-v') option.
If one of the files named with `--create' (`-c') is a directory, then
the operation of tar
is more complicated.
FIXME: xref Tar and Directories, FIXME: the last section of this tutorial, for more information.
If you don't specify the `--file=archive-name' (`-f archive-name') option, then tar
will use
a default. Usually this default is some physical tape drive attached to
your machine. If there is no tape drive attached, or the default is not
meaningful, then tar
will print an error message. This error message
might look roughly like one of the following:
tar: can't open /dev/rmt8 : No such device or address tar: can't open /dev/rsmt0 : I/O error
If you get an error like this, mentioning a file you didn't specify
(`/dev/rmt8' or `/dev/rsmt0' in the examples above), then tar
is using a default value for `--file=archive-name' (`-f archive-name'). You should generally specify a
`--file=archive-name' (`-f archive-name') argument whenever you use tar
, rather than relying
on a default.
To create a new archive, use the `--create' (`-c') option to
tar
. You can use options to specify the name and format of
the archive (as well as other characteristics), and you can use
file name arguments to specify which files to put in the archive.
If you don't use any options or file name arguments, tar
will
use default values.
FIXME: xref Creating Example, for more information about the `--create' (`-c') option.
Go to the previous, next section.