pax(1)


pax -- portable archive interchange

Synopsis

   /u95/bin/pax [-cdnv] [-f archive] [-s replstr][pattern...]
   

pax -r [-cdiknuvy] [-f archive][-p string][-s replstr] [pattern...]

pax -w[-dituvyX] [-b blocksize] [[-a] -f archive][-s replstr] [-x format][file...]

pax -r -w [-diklntuvyX][-p string][-s replstr][file...] directory

Description

The pax utility reads, writes, and lists members of archive files, and copies directory hierarchies. A variety of archive formats are supported; see the -x format option.

The four forms listed in the SYNOPSIS section are referred to as modes of operation. These modes represent the different combinations of the -r and -w options. The four modes of operation are ``list'', ``read'', ``write'' and ``copy''.

pattern is a pattern matching one or more pathnames of archive members. The default, if no pattern is specified, is to select all members in the archive. directory is the destination directory pathname for copy mode. file is a pathname of a file to be copied or archived.

Modes


``list mode''
When neither -r nor -w are specified, pax writes the names of the members of the archive file read from the standard input, with pathnames matching the specified patterns, to standard output. If a named file is of type directory, the file hierarchy rooted at the file is written out as well.

``read mode''
When -r is specified and -w is not, pax extracts the members of the archive file read from the standard input, with pathnames matching the specified patterns. If an extracted file is of type directory, the file hierarchy rooted at that file is extracted as well. The extracted file is created relative to the current file hierarchy.

``write mode''
When -w is specified and -r is not, pax writes the contents of the file operands to the standard output in an archive format. If no file operands are specified, a list of files to copy, one per line, is read from the standard input. A file of type directory includes all of the files in the file hierarchy rooted at the file.

``copy mode''
When both -r and -w are specified, pax copies the file operands to the destination directory.

If no file operands are specified, a list of files to copy, one per line, is read from the standard input. A file of type directory includes all files in the file hierarchy rooted at the file.

The effect of the copy is as if the copied files were written to an archive file and then extracted, except that there may be hard links between the original and the copied files. If the destination directory is a subdirectory of one of the files to be copied, the results are unspecified. It is an error for the file named by the directory operand not to exist, not be writable by the user, or not be a file of type directory.

In read or copy modes, if intermediate directories are necessary to extract an archive member, pax performs actions equivalent to the mkdir(2) function, called with the following arguments:

The supported archive formats are automatically detected on input. A single archive can span multiple files. If any specified pattern or file operands are not matched by at least one file or archive member, pax writes a diagnostic message to standard error for each one that did not match and exits with a non-zero exit status.

Options

The following options are supported:

-r
Read an archive file from standard input.

-w
Write files to the standard output in the specified archive format.

-a
Append files to the end of the archive.

-b blocksize
Block the output at a positive decimal integer number of bytes per write to the archive file. Blocking is automatically determined on input. Portable applications must not specify a blocksize value larger than 32256. Use the -x option to specify the output archive format.

-c
Match all file or archive members except those specified by the pattern or file operands.

-d
Cause files of type directory being copied or archived or archive members of type directory being extracted to match only the file or archive member itself and not the file hierarchy rooted at the file.

-f archive
Specify the pathname of the input or output archive, overriding the default standard input or standard output.

-i
Interactively rename files or archive members. For each archive member matching a pattern operand or file matching a file operand, a prompt is written to the file /dev/tty. The prompt contains the name of the file or archive member, but the format is otherwise unspecified. A line is then read from /dev/tty. 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. The pax utility immediately exits with a non-zero exit status if end-of-file is encountered when reading a response or if /dev/tty cannot be opened for reading and writing.

-k
Prevents the overwriting of existing files.

-l
Link files. In copy mode, hard links are made between the source and destination file hierarchies whenever possible.

-n
Select the first archive member that matches each pattern operand. No more than one archive member is matched for each pattern.

-p string
Specify one or more file characteristic options or privileges. The string argument must be a string specifying file characteristics to be retained or discarded on extraction. The string consists of the specification characters a, e, m, o, and p. Other characters can be included. Multiple characteristics can be concatenated within the same string and multiple -p options can be specified. The meaning of the specification characters are:

a
Do not preserve file access time.

e
Preserve the user ID, group ID, file mode bits, access time, modification time and other file characteristics.

m
Do not preserve file modification times.

o
Preserve the user ID and group ID.

p
Preserve the file mode bits.

If neither e nor o is specified, or the user ID and group ID are not preserved for any reason, pax does not set the S_ISUID and S_ISGID bits of the file mode.

If the preservation of any of these items fails for any reason, pax writes a diagnostic message to standard error. Failure to preserve these items affects the final exit status, but does not cause the extracted file to be deleted.

If file-characteristic letters in any of the string arguments are duplicated or conflict with each other, the ones given last take precedence. For example, if -p eme is specified, file modification times will be preserved.


-e replstr
Modify file or archive member names named by pattern or file operands according to the substitution expression replstr, using the syntax of the ed utility.

Any non-null character can be used as a delimiter. Multiple -s expressions can be specified; the expressions are applied in the sequence specified, terminating with the first successful substitution. The optional trailing g is as defined in the ed utility. The optional trailing p causes successful substitutions to be written to standard error. File or archive member names that substitute to the empty string are ignored when reading and writing archives.


-t
Cause the access times of the archived files to be the same as they were before being read by pax.

-u
Ignore files that have a less recent file modification time than a pre-existing file or archive member with the same name. In read mode, 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. In write mode, an archive file member with the same name as a file in the file system is superseded if the file is newer than the archive member. It is unspecified if this is accomplished by actual replacement in the archive or by appending to the archive. In copy mode, 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
In list mode, produce a verbose table of contents. Otherwise, write archive member pathnames to standard error.

-x format
Specify the output archive format. The pax utility recognizes the following formats:

cpio
The extended cpio interchange format; see cpio(1). The default blocksize for this format for character special archive files is 5120. Implementations support all blocksize values less than or equal to 32256 that are multiples of 512.

ustar
The extended tar interchange format; see tar(1). The default blocksize for this format for character special archive files is 10240. Implementations support all blocksize values less than or equal to 32256 that are multiples of 512.

The pax command has been updated so that, when the ustar format is specified, it will handle files larger than 2GB.

Any attempt to append to an archive file in a format different from the existing archive format causes pax to exit immediately with a non-zero exit status.


-X
When traversing the file hierarchy specified by a pathname, pax does not descend into directories that have a different device ID.

-y
An old option equivalent to the -i option with a single period and an empty line.

The options that operate on the names of files or archive members (-c, -i, -n, -s, -u, and -v) interact. In read mode, the archive members are selected based on the user-specified pattern operands as modified by the -c, -n, and -u options. Then, any -s and -i options modify, in that sequence, the names of the selected files. The -v option writes names resulting from these modifications.

In write mode, the files are selected based on the user-specified pathnames as modified by the -n and -u options. Then, any -s and -i options, in that sequence, modify the names of these selected files. The -v option writes names resulting from these modifications.

If both the -u and -v options are specified, pax does not consider a file selected unless it is newer than the file to which it is compared.

Environment variables

The following environment variables affect the execution of pax:

LANG
Provide a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization variables contains an invalid setting, the utility behaves as if none of the variables had been defined.

LC_ALL
If set to a non-empty string value, overrides the values of all the other internationalization variables.

LC_COLLATE
Determine the locale for the behavior of ranges, equivalence classes and multi-character collating elements used in the pattern matching expressions for the pattern operand, the basic regular expression for the -s option, and the extended regular expression defined for the ``yesexpr'' locale keyword in the LC_MESSAGES category.

LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the behavior of character classes used in the extended regular expression defined for the ``yesexpr'' locale keyword in the LC_MESSAGES category, and pattern matching.

LC_MESSAGES
Determine the locale for the processing of affirmative responses that should be used to affect the format and content of diagnostic messages written to standard error.

LC_TIME
Determine the format and contents of date and time strings when the -v option is specified.

Consequences of errors

If pax 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 -p option is specified, a diagnostic message is written to standard error and a non-zero status is returned, but processing continues. In the case where pax cannot create a link to a file, pax does not, by default, create a second copy of the file.

If the extraction of a file from an archive is prematurely terminated by a signal or error, pax may have only partially extracted the file or (if the -n option was not specified) may have extracted a file of the same name as that specified by the user, but which is not the file the user wanted. Additionally, the file modes of extracted directories may have additional bits from the S_IRWXU mask set as well as incorrect modification and access times.

References

cpio(1), mkdir(2), tar(1)

Notices

The -p (privileges) option is used to reconcile differences between historical tar and cpio implementations. In particular, the two utilities use -m in different ways. The -p option provides a consistent means of extending the ways in which future file attributes can be addressed, such as for enhanced security systems or high-performance files. Although it may seem complex, there are really two modes that are most commonly used:

-p e
Preserve everything. This would be used by the historical superuser, someone with all the appropriate privileges, to preserve all aspects of the files as they are recorded in the archive. The e flag is the sum of o and p attributes.

-p p
Preserve the file mode bits. This would be used by the user with regular privileges who wished to preserve aspects of the file other than the ownership. The file times are preserved by default, but two other flags are offered to disable these and use the time of extraction.

The one pathname per line format of standard input precludes pathnames containing newline characters. Although such pathnames violate the portable filename guidelines, they may exist and their presence may inhibit usage of pax within shell scripts. This problem is inherited form historical archive programs. The problem can be avoided by listing filename arguments on the command line instead of on standard input.

The pax(1) utility supports the archival of files larger than 2 Gigabytes (2GB) in size when using the default ``ustar'' forma t. Files up to 2^63-1 bytes in size are supported. The pax utility also supports filenames and symbolic link filenames up to 1024 characters long when using the default ``ustar'' format. Older versions of pax will not be able to extract files larger than 2GB in size, or files whose filenames or symbolic link names are larger than 255 characters long.

Examples

The following command:

   pax -w -f /dev/rmt/1m 
copies the contents of the current directory to tape drive 1, medium density.

The following commands:

   mkdir newdir
   pax -rw olddir newdir

copy the olddir directory hierarchy to newdir.

   pax -r -s ',^//*usr//*,,' -f a.pax

reads the archive a.pax, with all files rooted in /usr in the archive extracted relative to the current directory.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 02 June 2005