hpux 10.20 - pax (1)
NAME
pax - Extracts, writes, and lists archive files
SYNOPSIS
Listing Member Files of Archived Files
pax [-cdnv] [-f archive] [-s replstr ] ... [pattern ...]
Extracting Archive Files
pax -r [-cdiknuvy] [-f archive] [-p string ] ... [-s replstr ] ...
[pattern ...]
Writing Archive Files
pax -w [-adituvXy] [-b blocking] [-f archive] [-s replstr ] ... [-x
format] [file ...]
Copying Files
pax -r -w [-diklntuvXy] [-p string ] ... [-s replstr ] ... [file ...]
directory
The pax command extracts, writes, and lists members of archive files.
It also copies files and directory hierarchies.
OPTIONS
-a Appends files to the end of the archive. Certain
devices might not support appending.
-b blocking Specifies the block size for output to be the positive
decimal integer of bytes specified by the blocking
argument. The block size value cannot exceed 32,256.
Blocking is automatically determined on input.
Do not specify a value for the blocking argument larger
than 32768. Default blocking when creating archives
depends on the archive format. (See the -x flag
description.)
-c Matches all file or archive members except those
specified by the pattern or file arguments.
-d Causes directories being copied or archived, or
archived directories being extracted, to match only the
directory or archived directory itself and not the
contents of the directory or archived directory.
-f archive Specifies the path of an archive file to be used
instead of standard input (when the -w flag is not
specified) or the standard output (when the -w flag is
specified but the -r flag is not). When specified with
the -a flag, any files written to the archive are
appended to the end of the archive.
-i Renames files or archives interactively. For each
archive member that matches the pattern argument or
file that matches a file argument, a prompt is written
to the terminal (/dev/tty) that contains the name of a
file or archive member. A line is then read from the
terminal. If this line is empty, the file or archive
member is skipped. If this line consists of a dot, the
file or archive member is processed with no
modification to its name. Otherwise, its name is
replaced with the contents of the line. The pax
command immediately exits with a nonzero exit status if
an End-of-File is encountered when reading a response
or if it cannot read or write to the terminal.
-k Prevents the pax command from writing over existing
files.
-l Links files when copying files. When both -r and -w
are specified, hard links are established between the
source and destination file hierarchies whenever
possible.
-n Selects the first archive member that matches each
pattern argument. No more than one archive member is
matched for each pattern (although members of type
directory will still match the file hierarchy rooted at
that file).
-p string Specifies one or more file characteristics to be
retained or discarded on extraction. The string
argument consists of the characters a, e, m, o, and p.
Multiple characteristics can be concatenated within the
same string and multiple -p flags can be specified. The
specification flags have the following meanings:
a Does not retain file-access times.
e Retains the user ID, group ID, access permission,
access time, and modification time.
m Does not retain file-modification times.
o Retains the user ID and the group ID.
p Retains the access permission.
Note that "retain" means that an attribute stored in
the archive is given to the extracted file, subject to
the permissions of the invoking process; otherwise, the
attribute is determined as part of the normal file
creation action.
If neither the e nor the o flag is specified, or the
user ID and group ID are not retained, the pax command
does not set the S_ISUID and S_ISGID bits of the access
permission. If the retention of any of these items
fails, the pax command writes a diagnostic message to
standard error. Failure to retain any of the items
affects the exit status, but does not cause the
extracted file to be deleted. If specification flags
are duplicated or conflict with each other, the ones
given last take precedence. For example, if -p eme is
specified, file-modification times are retained.
-r Reads an archive file from the standard input.
-s Modifies file-member or archive-member names specified
by the pattern or file arguments according to the
substitution expression replstr, using the syntax of
the ed command. The substitution expression has the
following format:
-s/old/new/[gp]
where as in the ed command, old is a basic regular
expression and new can contain an & (ampersand), \n (n
is a digit) back references, or subexpression matching.
The old string can also contain newline characters.
Any nonnull character can be used as a delimiter (the /
(slash) character is the delimiter in the previous
format). Multiple -s flag expressions can be specified;
the expressions are applied in the order specified,
terminating with the first successful substitution. The
optional trailing g character performs as in the ed
command. The optional trailing p character causes
successful substitutions to be written to the standard
error. File-member or archive-member names that
substitute to the empty string are ignored when reading
and writing archives.
-t Causes the access times of the archived files to be the
same as they were before being read by the pax command.
-u Ignores files that are older (having a less recent file
modification time) than a preexisting file or archive
member with the same name.
When extracting files ( -r flag), an archive member
with the same name as a file in the file system is
extracted if the archive member is newer than the file.
When writing files to an archive file ( -w flag), an
archive member with the same name as a file in the file
system is superseded if the file is newer than the
archive member.
When copying files to a destination directory ( -rw
flags), 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 Writes information about the process. If neither the -r
or -w flags are specified, the -v flag produces a
verbose table of contents that resembles the output of
ls -l; otherwise, archive-member pathnames are written
to standard error.
-w Writes files to the standard output in the specified
archive format.
-x format Specifies the output archive format. The pax command
recognizes the following formats:
cpio Extended cpio interchange format. The
default blocking value for this format
for character special archive files is
5120. Blocking values from 512 to 32,256
in increments of 512 are supported.
ustar Extended tar interchange format. This
is the default output archive format.
The default blocking value for this
format for character special archive
files is 10240. Blocking values from 512
to 32,256 in increments of 512 are
supported.
Any attempt to append to an archive file in a format
different from the existing archive format causes the
pax command to exit immediately with a nonzero exit
status.
-X When traversing the file hierarchy specified by a
pathname, the pax command does not descend into
directories that have a different device ID.
-y Prompts interactively for the disposition of each file.
Substitutions specified by -s flags are performed
before you are prompted for disposition. An EOF marker
or an input line starting with the character q causes
pax to exit. Otherwise, an input line starting with
anything other than y causes the file to be ignored.
This flag cannot be used in conjunction with the -i
flag.
Option Interaction and Processing Order
The flags that operate on the names of files or archive members ( -c,
-i, -n, -s, -u, and -v) interact as follows.
When extracting files (-r flag), archive members are selected, using
the modified names, according to the user-specified pattern arguments
as modified by the -c, -n, and -u flags. Then, any -s and -i flags
modify, in that order, the names of the selected files. The -v flag
writes the names resulting from these modifications.
When writing files to an archive file (-w flag), or when copying
files, the files are selected according to the user-specified
pathnames as modified by the -n and -u flags. Then, any -s and -i
flags modify, in that order, the names resulting from these
modifications. The -v flag writes the names resulting from these
modifications.
If both the -u and -n flags are specified, the pax command does not
consider a file selected unless it is newer than the file to which it
is compared.
DESCRIPTION
The pax command extracts and writes member files of archive files;
writes lists of the member files of archives; and copies directory
hierarchies. The -r and -w flags specify the archive operation
performed by the pax command.
The pattern argument specifies a pattern that matches one or more
paths of archive members. A \ (backslash) character is not recognized
in the pattern argument and it prevents the subsequent character from
having any special meaning. If no pattern argument is specified, all
members are selected in the archive.
If a pattern argument is specified, but no archive members are found
that match the pattern specified, the pax command detects the error,
exits with a nonzero exit status, and writes a diagnostic message.
The pax command can read both tar and cpio archives. In the case of
cpio, this means that pax can read ASCII archives (which are created
with cpio -c) and binary archives (which are created without the -c
flag). The supported archive formats are automatically detected on
input.
pax can also write archives that tar and cpio can read; by default,
pax writes archives in the ustar extended tar interchange format. pax
also writes ASCII cpio archives; use the -x cpio flag to specify this
extended cpio output format.
Listing Member Files of Archived Files
When neither the -r nor the -w flags are specified, the pax command
writes the names of the members of the archive file read from the
standard input, with pathnames matching the specified patterns, to the
standard output. If a named file is a directory, the file hierarchy
contained in the directory is also written. You can specify the pax
command without the -r or -w flags with the -c, -d, -f, -n, -s, and -v
flags, and with the pattern argument.
If neither the -r or -w flags are included, pax lists the contents of
the specified archive, one file per line. pax lists hard link
pathnames as follows:
pathname==linkname
pax lists symbolic link pathnames as follows:
pathname->linkname
In both of the preceding cases, pathname is the name of the file that
is being extracted, and linkname is the name of a file that appeared
earlier in the archive.
If the -v flag is specified, the listing of hard link pathnames is
output in the ls -l command format.
Extracting Archive Files
When the -r flag is specified, but the -w flag is not, the pax command
extracts the members of an archive file read from the standard input,
and with pathnames matching the pattern argument if one is specified.
If an extracted file is a directory, the file hierarchy contained in
the directory is also extracted. The extracted files are created
relative to the current file hierarchy. The -r flag can be specified
with the -c, -d, -f, -n, -s, and -v flags, and a pattern argument.
The access and modification times of the extracted files are the same
as the archived files. The access permissions of the extracted files
remain as archived unless affected by the user's default file creation
mode. The S_ISUID and S_ISGID bits of the extracted files are cleared.
If intermediate directories are necessary to extract an archive
member, the pax command creates the directories with access
permissions set as the bitwise inclusive OR of the values of the
S_IRWXU, S_IRWXG,and S_IRWXO options.
If the selected archive format supports the specification of linked
files (both the tar and cpio formats do), it is an error if these
files cannot be linked when the archive is extracted. pax informs you
of the error and continues processing.
Writing Archive Files
When the -w flag is specified and the -r flag is not, the pax command
writes the contents of the files specified by the file arguments to
the standard output in an archive format. If no file arguments are
specified, a list of files to copy, one per line, is read from the
standard input. When the file argument specifies a directory, all of
the files contained in the directory are written. The -w flag can be
specified with the -b, -d, -f, -i, -s, -t, -u, -v, -x, and -X flags
and with file arguments.
If -w is specified, but no files are specified, standard input is
used. If neither -f or -w are specified, standard input must be an
archive file.
Copying Files
When both the -r and -w flags are specified, the pax command copies
the files specified by the file arguments to the destination directory
specified by the directory argument. If no file arguments are
specified, a list of files to copy, one per line, is read from the
standard input. If a specified file is a directory, the file hierarchy
contained in the directory is also copied. The -r and -w flags can be
specified with the -d, -i, -k, -l, -p, -n, -s, -t, -u, -v, and -X
flags and with the file arguments. A directory argument must be
specified.
Copied files are the same as if they were written to an archive file
and subsequently extracted, except that there may be hard links
between the original and the copied files.
RETURN VALUE
The pax command returns a value of 0 (zero) if all files were
successfully processed; otherwise, pax returns a value greater than 0
(zero).
EXAMPLES
To copy the contents of the current directory to the tape drive,
enter:
pax -w -f /dev/rmt/0m .
To copy the olddir directory hierarchy to newdir enter:
mkdir newdir
cd olddir
pax -rw olddir newdir
To read the archive a.pax, with all files rooted in the directory /usr
in the archive extracted relative to the current directory, enter:
pax -r -s ',//*usr//*,,' -f a.pax
All of the preceding examples create archives in tar format.
The following pairs of commands demonstrate conversions from cpio and
tar to pax. In all cases, the examples show comparable command-line
usage rather than identical output formats. The -x flag can be
specified to the pax commands shown here, producing archives to select
specific output formats:
ls * | cpio -ocv
pax -wdv *
find /mydir -type f -print | cpio -oc
find /mydir -type f -print | pax -w
cpio -icdum < archive
pax -r < archive
(cd /fromdir;find . -print) | cpio -pdlum /todir
pax -rwl /fromdir /todir
tar cf archive *
pax -w -f archive * PP
tar xfv - < archive
pax -rv < archive
(cd /fromdir; tar cf - . ) | (cd /todir; tar xf -)
pax -rw /fromdir /todir
Notes
When you use the -i flag (interactively renames files) on files to
which there are hard links, pax does not create hard links to the
renamed files.
WARNINGS
Because of industry standards and interoperability goals, pax does not
support the archival of files larger than 2GB or files that have
user/group IDs greater than 60K. Files with user/group IDs greater
than 60K are archived and restored under the user/group ID of the
current process.
AUTHOR
pax was developed by Mark H. Colburn, OSF, and HP.
SEE ALSO
ed(1), tar(4).
STANDARDS CONFORMANCE
pax: XPG4, POSIX.2
This implementation of pax is based upon a POSIX.2 draft
specification. HP intends to update pax to meet the final POSIX.2
Standard once it completes, and thus the pax implementation is likely
to change in a future release of HP-UX, possibly in ways incompatible
with the current implementation. HP recommends using the current
implementation only if absolutely necessary.