Go to the previous, next section.

Changing the Archive Name

(This message will disappear, once this node revised.)

By default, tar uses an archive file name compiled in when tar was built. Usually this refers to some physical tape drive on the machine. Often, the installer of tar didn't set the default to anything meaningful at all.

As a result, most uses of tar need to tell tar where to find (or create) the archive. The `--file=archive-name' (`-f archive-name') option selects another file to use as the archive.

If the archive file name includes a colon (`:'), then it is assumed to be a file on another machine. If the archive file is `user@host:file', then file is used on the host host. The remote host is accessed using the rsh program, with a username of user. If the username is omitted (along with the `@' sign), then your user name will be used. (This is the normal rsh behavior.) It is necessary for the remote machine, in addition to permitting your rsh access, to have the `/usr/ucb/rmt' program installed. If you need to use a file whose name includes a colon, then the remote tape drive behavior can be inhibited by using the `--force-local' option.

If the file name you give to `--file=archive-name' (`-f archive-name') is a single dash (`-'), then tar will read the archive from (or write it to) standard input (or standard output).

The Name of an Archive

An archive can be saved as a file in the file system, sent through a pipe or over a network, or written to an I/O device such as a tape or disk drive. To specify the name of the archive, use the `--file=archive-name' (`-f archive-name') option.

An archive name can be the name of an ordinary file or the name of an I/O device. tar always needs an archive name--if you do not specify an archive name, the archive name comes from the environment variable TAPE or, if that variable is not specified, a default archive name, which is usually the name of tape unit zero (ie. /dev/tu00).

If you use `-' as an archive-name, tar reads the archive from standard input (when listing or extracting files), or writes it to standard output (when creating an archive). If you use `-' as an archive-name when modifying an archive, tar reads the original archive from its standard input and writes the entire new archive to its standard output.

FIXME: does standard input and output redirection work with all
FIXME: operations?  
FIXME: need example for standard input and output (screen and keyboard?)

To specify an archive file on a device attached to a remote machine, use the following:

--file=hostname:/dev/file name

tar will complete the remote connection, if possible, and prompt you for a username and password. If you use `--file=@hostname:/dev/file name', tar will complete the remote connection, if possible, using your username as the username on the remote machine.

FIXME: is this clear?

`--file=archive-name'
`-f archive-name'
Names the archive to create or operate on. Use in conjunction with any operation.

Selecting Archive Members

File Name arguments specify which files in the file system tar operates on, when creating or adding to an archive, or which archive members tar operates on, when reading or deleting from an archive. (

FIXME: pxref Reading and Writing
.)

To specify file names, you can include them as the last arguments on the command line, as follows:

tar operation [option1 option2 ..] [file name-1 file name-2 ...]

If you specify a directory name as a file name argument, all the files in that directory are operated on by tar.

If you do not specify files when tar is invoked, tar operates on all the non-directory files in the working directory (if the operation is `--create' (`-c')), all the archive members in the archive (if a read operation is specified), or does nothing (if any other operation is specified).

When specifying the names of files or members to tar, it by default takes the names of the files from the command line. There are other ways, however, to specify file or member names, or to modify the manner in which tar selects the files or members upon which to operate. In general, these methods work both for specifying the names of files and archive members.

Go to the previous, next section.