HP-UX Reference (11i v2 04/09) - 1 User Commands N-Z (vol 2)

t
tar(1) tar(1)
NAME
tar - tape file archiver
SYNOPSIS
tar [-]key [arg ...] [file
-C directory] ...
DESCRIPTION
The
tar command saves and restores archives of files on a magnetic tape, a flexible disk, or a regular
file. The default archive file is
/dev/rmt/0m. See the -f option below. Its actions are controlled by
the key argument.
Arguments
key is a string of characters containing exactly one function letter and zero or more function
modifiers, specified in any order. Whitespace is not permitted in key. The key string can
be preceded by a hyphen (
-), as when specifying options in other HP-UX commands, but it
is not necessary.
arg ... The
b and f function modifiers each require an arg argument (see below). If both
b and f
are specified, the order of the arg arguments must match the order of the modifiers. If
specified, the arg arguments must be separated from the key and each other by whi-
tespace.
file specifies a file being saved or restored. If file is a directory name, it refers to the files and
(recursively) the subdirectories contained in that directory.
-C directory causes tar to perform a chdir() to directory (see chdir(2)). Subsequent file and
-C
directory arguments are relative to directory . This allows multiple directories not related
by a close or common parent to be archived using short relative path names.
The value of file is stored in the archive. The value of directory is not stored.
Function Keys
The function portion of the key is specified by exactly one of the following letters:
c Create a new archive. Write from the beginning of the archive instead of appending after the
last file. Any previous information in the archive is overwritten.
r Add the named file to the end of the archive. The same blocking factor used to create the
archive must be used to append to it. This option cannot be used if the archive is a tape.
t List the names of all the files in the archive. Adding the v function modifier expands this list-
ing to include the file modes and owner numbers. The names of all files are listed each time
they occur on the tape.
u Add any named file to the archive if it is not already present or has been modified since it was
last written in the archive. The same blocking factor used to create the archive must be used
to update it.
x Extract the named file from the archive and restore it to the system. If a named file matches a
directory whose contents were written to the archive, this directory is (recursively) extracted.
If a named file on tape does not exist on the system, the file is created as follows:
The user, group, and other protections are restored from the tape.
The modification time is restored from the tape unless the
m function modifier is
specified.
The file user ID and group ID are normally those of the restoring process.
The set-user-ID, set-group-ID, and sticky bits are not set automatically. The
o and p
function modifiers control the restoration of protection; see below for more details.
If the files exist, their modes are not changed, but the set-user-id, set-group-id and sticky bits
are cleared. If no file argument is given, the entire content of the archive is extracted. Note
that if several files with the same name are on the archive, the last one overwrites all earlier
ones.
Function Modifier Keys
The following function modifiers can be used in addition to the function letters listed above (note that
some modifiers are incompatible with some functions):
HP-UX 11i Version 2: September 2004 1 Hewlett-Packard Company Section 1907