tar: file

1 
1 6.1 Choosing and Naming Archive Files
1 =====================================
1 
1 By default, 'tar' uses an archive file name that was compiled when it
1 was built on the system; usually this name refers to some physical tape
1 drive on the machine.  However, the person who installed 'tar' on the
1 system may not have set the default to a meaningful value as far as most
1 users are concerned.  As a result, you will usually want to tell 'tar'
1 where to find (or create) the archive.  The '--file=ARCHIVE-NAME' ('-f
1 ARCHIVE-NAME') option allows you to either specify or name a file to use
1 as the archive instead of the default archive file location.
1 
1 '--file=ARCHIVE-NAME'
1 '-f ARCHIVE-NAME'
1      Name the archive to create or operate on.  Use in conjunction with
1      any operation.
1 
1    For example, in this 'tar' command,
1 
1      $ tar -cvf collection.tar blues folk jazz
1 
1 'collection.tar' is the name of the archive.  It must directly follow
1 the '-f' option, since whatever directly follows '-f' _will_ end up
1 naming the archive.  If you neglect to specify an archive name, you may
1 end up overwriting a file in the working directory with the archive you
1 create since 'tar' will use this file's name for the archive name.
1 
1    An archive can be saved as a file in the file system, sent through a
1 pipe or over a network, or written to an I/O device such as a tape,
1 floppy disk, or CD write drive.
1 
1    If you do not name the archive, 'tar' uses the value of the
1 environment variable 'TAPE' as the file name for the archive.  If that
1 is not available, 'tar' uses a default, compiled-in archive name,
1 usually that for tape unit zero (i.e., '/dev/tu00').
1 
1    If you use '-' as an ARCHIVE-NAME, 'tar' reads the archive from
1 standard input (when listing or extracting files), or writes it to
1 standard output (when creating an archive).  If you use '-' as an
1 ARCHIVE-NAME when modifying an archive, 'tar' reads the original archive
1 from its standard input and writes the entire new archive to its
1 standard output.
1 
1    The following example is a convenient way of copying directory
1 hierarchy from 'sourcedir' to 'targetdir'.
1 
1      $ (cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)
1 
1    The '-C' option allows to avoid using subshells:
1 
1      $ tar -C sourcedir -cf - . | tar -C targetdir -xpf -
1 
1    In both examples above, the leftmost 'tar' invocation archives the
1 contents of 'sourcedir' to the standard output, while the rightmost one
1 reads this archive from its standard input and extracts it.  The '-p'
1 option tells it to restore permissions of the extracted files.
1 
1    To specify an archive file on a device attached to a remote machine,
1 use the following:
1 
1      --file=HOSTNAME:/DEV/FILE-NAME
1 
1 'tar' will set up the remote connection, if possible, and prompt you for
1 a username and password.  If you use '--file=@HOSTNAME:/DEV/FILE-NAME',
1 'tar' will attempt to set up the remote connection using your username
1 as the username on the remote machine.
1 
1    If the archive file name includes a colon (':'), then it is assumed
1 to be a file on another machine.  If the archive file is
1 'USER@HOST:FILE', then FILE is used on the host HOST.  The remote host
1 is accessed using the 'rsh' program, with a username of USER.  If the
1 username is omitted (along with the '@' sign), then your user name will
1 be used.  (This is the normal 'rsh' behavior.)  It is necessary for the
1 remote machine, in addition to permitting your 'rsh' access, to have the
1 'rmt' program installed (this command is included in the GNU 'tar'
1 distribution and by default is installed under 'PREFIX/libexec/rmt',
1 where PREFIX means your installation prefix).  If you need to use a file
1 whose name includes a colon, then the remote tape drive behavior can be
1 inhibited by using the '--force-local' option.
1 
1    When the archive is being created to '/dev/null', GNU 'tar' tries to
1 minimize input and output operations.  The Amanda backup system, when
1 used with GNU 'tar', has an initial sizing pass which uses this feature.
1