NAME
SYNOPSIS
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
k -words
DESCRIPTION
will read, write, and list the members of an archive file,
and will copy directory hierarchies.
operation is independent of the specific archive format,
and supports a wide variety of different archive formats.
A list of supported archive formats can be found under the description of the
option.
The presence of the
and the
options specifies which of the following functional modes
will operate under:
and
- <none>
will write to
a table of contents of the members of the archive file read from
whose pathnames match the specified
The table of contents contains one filename per line
and is written using single line buffering.
- r
extracts the members of the archive file read from the
with pathnames matching the specified
The archive format and blocking is automatically determined on input.
When an extracted file is a directory, the entire file hierarchy
rooted at that directory is extracted.
All extracted files are created relative to the current file hierarchy.
The setting of ownership, access and modification times, and file mode of
the extracted files are discussed in more detail under the
option.
- w
writes an archive containing the
operands to
using the specified archive format.
When no
operands are specified, a list of files to copy with one per line is read from
When a
operand is also a directory, the entire file hierarchy rooted
at that directory will be included.
- w
copies the
operands to the destination
When no
operands are specified, a list of files to copy with one per line is read from
the
When a
operand is also a directory the entire file
hierarchy rooted at that directory will be included.
The effect of the
is as if the copied files were written to an archive file and then
subsequently extracted, except that there may be hard links between
the original and the copied files (see the
option below).
The destination
must not be one of the
operands or a member of a file hierarchy rooted at one of the
operands.
The result of a
under these conditions is unpredictable.
While processing a damaged archive during a
or
operation,
will attempt to recover from media defects and will search through the archive
to locate and process the largest number of archive members possible (see the
option for more details on error handling).
OPERANDS
The
operand specifies a destination directory pathname.
If the
operand does not exist, or it is not writable by the user,
or it is not of type directory,
will exit with a non-zero exit status.
The
operand is used to select one or more pathnames of archive members.
Archive members are selected using the pattern matching notation described
by
fnmatch(3)
When the
operand is not supplied, all members of the archive will be selected.
When a
matches a directory, the entire file hierarchy rooted at that directory will
be selected.
When a
operand does not select at least one archive member,
will write these
operands in a diagnostic message to
and then exit with a non-zero exit status.
The
operand specifies the pathname of a file to be copied or archived.
When a
operand does not select at least one archive member,
will write these
operand pathnames in a diagnostic message to
and then exit with a non-zero exit status.
OPTIONS
The following options are supported:
- r
Read an archive file from
and extract the specified
If any intermediate directories are needed in order to extract an archive
member, these directories will be created as if
mkdir(2)
was called with the bitwise inclusive
of
and
as the mode argument.
When the selected archive format supports the specification of linked
files and these files cannot be linked while the archive is being extracted,
will write a diagnostic message to
and exit with a non-zero exit status at the completion of operation.
- w
Write files to the
in the specified archive format.
When no
operands are specified,
is read for a list of pathnames with one per line without any leading or
trailing
- a
Append
to the end of an archive that was previously written.
If an archive format is not specified with a
option, the format currently being used in the archive will be selected.
Any attempt to append to an archive in a format different from the
format already used in the archive will cause
to exit immediately
with a non-zero exit status.
The blocking size used in the archive volume where writing starts
will continue to be used for the remainder of that archive volume.
Many storage devices are not able to support the operations necessary
to perform an append operation.
Any attempt to append to an archive stored on such a device may damage the
archive or have other unpredictable results.
Tape drives in particular are more likely to not support an append operation.
An archive stored in a regular file system file or on a disk device will
usually support an append operation.
blocksize
When
an archive,
block the output at a positive decimal integer number of
bytes per write to the archive file.
The
must be a multiple of 512 bytes with a maximum of 64512 bytes.
Archives larger than 32256 bytes violate the
standard and will not be portable to all systems.
A
can end with
or
to specify multiplication by 1024 (1K) or 512, respectively.
A pair of
can be separated by
to indicate a product.
A specific archive device may impose additional restrictions on the size
of blocking it will support.
When blocking is not specified, the default
is dependent on the specific archive format being used (see the
option).
c
Match all file or archive members
those specified by the
and
operands.
d
Cause files of type directory being copied or archived, or archive members of
type directory being extracted, to match only the directory file or archive
member and not the file hierarchy rooted at the directory.
archive
Specify
as the pathname of the input or output archive, overriding the default
(for
and
or
(for
A single archive may span multiple files and different archive devices.
When required,
will prompt for the pathname of the file or device of the next volume in the
archive.
i
Interactively rename files or archive members.
For each archive member matching a
operand or each file matching a
operand,
will prompt to
giving the name of the file, its file mode and its modification time.
will then read a line from
If this line is blank, the file or archive member is skipped.
If this line consists of a single period, the
file or archive member is processed with no modification to its name.
Otherwise, its name is replaced with the contents of the line.
will immediately exit with a non-zero exit status if
is encountered when reading a response or if
cannot be opened for reading and writing.
j
Filter archive through bzip2.
k
Do not overwrite existing files.
l
(The lowercase letter ``ell.'') Link files.
In the
mode
hard links are made between the source and destination file hierarchies
whenever possible.
n
Select the first archive member that matches each
operand.
No more than one archive member is matched for each
When members of type directory are matched, the file hierarchy rooted at that
directory is also matched (unless
is also specified).
options
Information to modify the algorithm for extracting or writing archive files
which is specific to the archive format specified by
In general,
take the form:
string
Specify one or more file characteristic options (privileges).
The
option-argument is a string specifying file characteristics to be retained or
discarded on extraction.
The string consists of the specification characters
and
Multiple characteristics can be concatenated within the same string
and multiple
options can be specified.
The meaning of the specification characters are as follows:
a
Do not preserve file access times.
By default, file access times are preserved whenever possible.
e
the user ID, group ID, file mode bits,
file access time, and file modification time.
This is intended to be used by
someone with all the appropriate privileges, in order to preserve all
aspects of the files as they are recorded in the archive.
The
flag is the sum of the
and
flags.
m
Do not preserve file modification times.
By default, file modification times are preserved whenever possible.
o
Preserve the user ID and group ID.
p
the file mode bits.
This intended to be used by a
with regular privileges who wants to preserve all aspects of the file other
than the ownership.
The file times are preserved by default, but two other flags are offered to
disable this and use the time of extraction instead.
In the preceding list,
indicates that an attribute stored in the archive is given to the
extracted file, subject to the permissions of the invoking
process.
Otherwise the attribute of the extracted file is determined as
part of the normal file creation action.
If neither the
nor the
specification character is specified, or the user ID and group ID are not
preserved for any reason,
will not set the
and
bits of the file mode.
If the preservation of any of these items fails for any reason,
will write a diagnostic message to
Failure to preserve these items will affect the final exit status,
but will not cause the extracted file to be deleted.
If the file characteristic letters in any of the string option-arguments are
duplicated or conflict with each other, the one(s) given last will take
precedence.
For example, if
is specified, file modification times are still preserved.
replstr
Modify the file or archive member names specified by the
or
operands according to the substitution expression
using the syntax of the
ed(1)
utility regular expressions.
The format of these regular expressions are:
As in
ed(1)
is a basic regular expression and
can contain an ampersand (&), \n (where n is a digit) back-references,
or subexpression matching.
The
string may also contain
characters.
Any non-null character can be used as a delimiter (/ is shown here).
Multiple
expressions can be specified.
The expressions are applied in the order they are specified on the
command line, terminating with the first successful substitution.
The optional trailing
continues to apply the substitution expression to the pathname substring
which starts with the first character following the end of the last successful
substitution. The first unsuccessful substitution stops the operation of the
option.
The optional trailing
will cause the final result of a successful substitution to be written to
in the following format:
File or archive member names that substitute to the empty string
are not selected and will be skipped.
t
Reset the access times of any file or directory read or accessed by
to be the same as they were before being read or accessed by
u
Ignore files that are older (having a less recent file modification time)
than a pre-existing file or archive member with the same name.
During
an archive member with the same name as a file in the file system will be
extracted if the archive member is newer than the file.
During
a file system member with the same name as an archive member will be
written to the archive if it is newer than the archive member.
During
the file in the destination hierarchy is replaced by the file in the source
hierarchy or by a link to the file in the source hierarchy if the file in
the source hierarchy is newer.
v
During a
operation, produce a verbose table of contents using the format of the
ls(1)
utility with the
option.
For pathnames representing a hard link to a previous member of the archive,
the output has the format:
For pathnames representing a symbolic link, the output has the format:
Where <ls -l listing> is the output format specified by the
ls(1)
utility when used with the
option.
Otherwise for all the other operational modes
pathnames are written and flushed to
without a trailing
as soon as processing begins on that file or
archive member.
The trailing
is not buffered, and is written only after the file has been read or written.
format
Specify the output archive format, with the default format being
currently supports the following formats:
cpio
The extended cpio interchange format specified in the
standard.
The default blocksize for this format is 5120 bytes.
Inode and device information about a file (used for detecting file hard links
by this format) which may be truncated by this format is detected by
and is repaired.
bcpio
The old binary cpio format.
The default blocksize for this format is 5120 bytes.
This format is not very portable and should not be used when other formats
are available.
Inode and device information about a file (used for detecting file hard links
by this format) which may be truncated by this format is detected by
and is repaired.
sv4cpio
The System V release 4 cpio.
The default blocksize for this format is 5120 bytes.
Inode and device information about a file (used for detecting file hard links
by this format) which may be truncated by this format is detected by
and is repaired.
sv4crc
The System V release 4 cpio with file crc checksums.
The default blocksize for this format is 5120 bytes.
Inode and device information about a file (used for detecting file hard links
by this format) which may be truncated by this format is detected by
and is repaired.
tar
The old BSD tar format as found in BSD4.3.
The default blocksize for this format is 10240 bytes.
Pathnames stored by this format must be 100 characters or less in length.
Only
files,
and
will be archived (other file system types are not supported).
For backwards compatibility with even older tar formats, a
option can be used when writing an archive to omit the storage of directories.
This option takes the form:
ustar
The extended tar interchange format specified in the
standard.
The default blocksize for this format is 10240 bytes.
Pathnames stored by this format must be 250 characters or less in length.
will detect and report any file that it is unable to store or extract
as the result of any specific archive format restrictions.
The individual archive formats may impose additional restrictions on use.
Typical archive format restrictions include (but are not limited to):
file pathname length, file size, link pathname length, and the type of the
file.
j
Filter archive through bzip2.
bytes
Limit the number of bytes written to a single archive volume to
The
limit can end with
or
to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
A pair of
limits can be separated by
to indicate a product.
Only use this option when writing an archive to a device which supports
an end of file read condition based on last (or largest) write offset
(such as a regular file or a tape drive).
The use of this option with a floppy or hard disk is not recommended.
D
This option is the same as the
option, except that the file inode change time is checked instead of the
file modification time.
The file inode change time can be used to select files whose inode information
(e.g. UID, GID, etc.) is newer than a copy of the file in the destination
limit
Limit the number of consecutive read faults while trying to read a flawed
archive to
With a positive
will attempt to recover from an archive read error and will
continue processing starting with the next file stored in the archive.
A
of 0 will cause
to stop operation after the first read error is detected on an archive volume.
A
of
will cause
to attempt to recover from read errors forever.
The default
is a small positive number of retries.
Using this option with
should be used with extreme caution as
may get stuck in an infinite loop on a very badly flawed archive.
group
Select a file based on its
name, or when starting with a
a numeric gid.
A '\' can be used to escape the
Multiple
options may be supplied and checking stops with the first match.
H
Follow only command line symbolic links while performing a physical file
system traversal.
L
Follow all symbolic links to perform a logical file system traversal.
P
Do not follow symbolic links, perform a physical file system traversal.
This is the default mode.
[from_date][,to_date][/[c][m]]
Allow files to be selected based on a file modification or inode change
time falling within a specified time range of
to
(the dates are inclusive).
If only a
is supplied, all files with a modification or inode change time
equal to or younger are selected.
If only a
is supplied, all files with a modification or inode change time
equal to or older will be selected.
When the
is equal to the
only files with a modification or inode change time of exactly that
time will be selected.
When
is in the
or
mode, the optional trailing field
can be used to determine which file time (inode change, file modification or
both) are used in the comparison.
If neither is specified, the default is to use file modification time only.
The
specifies the comparison of file modification time (the time when
the file was last written).
The
specifies the comparison of inode change time (the time when the file
inode was last changed; e.g. a change of owner, group, mode, etc).
When
and
are both specified, then the modification and inode change times are
both compared.
The inode change time comparison is useful in selecting files whose
attributes were recently changed or selecting files which were recently
created and had their modification time reset to an older time (as what
happens when a file is extracted from an archive and the modification time
is preserved).
Time comparisons using both file times is useful when
is used to create a time based incremental archive (only files that were
changed during a specified time range will be archived).
A time range is made up of six different fields and each field must contain two
digits.
The format is:
Where
is the last two digits of the year,
the first
is the month (from 01 to 12),
is the day of the month (from 01 to 31),
is the hour of the day (from 00 to 23),
the second
is the minute (from 00 to 59),
and
is the seconds (from 00 to 59).
The minute field
is required, while the other fields are optional and must be added in the
following order:
The
field may be added independently of the other fields.
Time ranges are relative to the current time, so
would select all files with a modification or inode change time
of 12:34 PM today or later.
Multiple
time range can be supplied and checking stops with the first match.
user
Select a file based on its
name, or when starting with a
a numeric UID.
A '\' can be used to escape the
Multiple
options may be supplied and checking stops with the first match.
X
When traversing the file hierarchy specified by a pathname,
do not descend into directories that have a different device ID.
See the
field as described in
stat(2)
for more information about device IDs.
Y
This option is the same as the
option, except that the inode change time is checked using the
pathname created after all the file name modifications have completed.
Z
This option is the same as the
option, except that the modification time is checked using the
pathname created after all the file name modifications have completed.
The options that operate on the names of files or archive members
and
interact as follows.
When extracting files during a
operation, archive members are
based only on the user specified pattern operands as modified by the
options.
Then any
and
options will modify in that order, the names of these selected files.
Then the
and
options will be applied based on the final pathname.
Finally, the
option will write the names resulting from these modifications.
When archiving files during a
operation, or copying files during a
operation, archive members are
based only on the user specified pathnames as modified by the
and
options (the
option only applies during a copy operation).
Then any
and
options will modify in that order, the names of these selected files.
Then during a
operation the
and the
options will be applied based on the final pathname.
Finally, the
option will write the names resulting from these modifications.
When one or both of the
or
options are specified along with the
option, a file is not considered selected unless it is newer
than the file to which it is compared.
EXAMPLES
The command:
copies the contents of the current directory to the device
The command:
gives the verbose table of contents for an archive stored in
The following commands:
will copy the entire
directory hierarchy to
The command:
reads the archive
with all files rooted in ``/usr'' into the archive extracted relative to the
current directory.
The command:
can be used to interactively select the files to copy from the current
directory to
The command:
will extract all files from the archive
which are owned by
with group
and will preserve all file permissions.
The command:
will update (and list) only those files in the destination directory
which are older (less recent inode change or file modification times) than
files with the same name found in the source file tree
STANDARDS
The
utility is a superset of the
standard.
The options
the archive formats
and the flawed archive handling during
and
operations are extensions to the
standard.
SEE ALSO
AUTHOR
Keith Muller at the University of California, San Diego.
ERRORS
will exit with one of the following values:
- 0
All files were processed successfully.
- 1
An error occurred.
Whenever
cannot create a file or a link when reading an archive or cannot
find a file when writing an archive, or cannot preserve the user ID,
group ID, or file mode when the
option is specified, a diagnostic message is written to
and a non-zero exit status will be returned, but processing will continue.
In the case where
cannot create a link to a file,
will not create a second copy of the file.
If the extraction of a file from an archive is prematurely terminated by
a signal or error,
may have only partially extracted a file the user wanted.
Additionally, the file modes of extracted files and directories
may have incorrect file bits, and the modification and access times may be
wrong.
If the creation of an archive is prematurely terminated by a signal or error,
may have only partially created the archive which may violate the specific
archive format specification.
If while doing a
detects a file is about to overwrite itself, the file is not copied,
a diagnostic message is written to
and when
completes it will exit with a non-zero exit status.