Linux and Unix pax command
Short for portable archive interchange, the pax command reads, writes, and writes lists of the members of archive files and copy directory hierarchies.
pax [-c] [-d] [-n] [-v] [-f archive] [-s replstr] [pattern]
pax -r [-c] [-d] [-i] [-k] [-n] [-u] [-v] [-f archive] [ -o options] [-p string] [ -s replstr] [pattern]
pax -w [-d] [-i] [-t] [-u] [-v] [-X] [-b blocksize] [-a] [-f archive] [-o options] [-s replstr] [-x format] [file]
pax -r -w [-d] [-i] [-k] [-l] [-n] [-t] [-u] [-v] [-X] [-p string] [-s replstr] [ file] directory
|-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.|
|-n||Select the first archive member that matches each pattern operand. No more than one archive member will be matched for each pattern (although members of type directory will still match the file hierarchy rooted at that file).|
|-v||In list mode, produce a verbose table of contents (see Standard Output). Otherwise, write archive member path names to standard error (see Standard Error).|
|-r||Read an archive file from standard input.|
|-i||Interactively rename files or archive members. For each archive member matching a pattern operand or file matching a file operand, a prompt will be written to the file /dev/tty. The prompt will contain the name of the file or archive member. A line will then be read from /dev/tty. If this line is blank, the file or archive member will be skipped. If this line consists of a single period, the file or archive member will be processed with no modification to its name. Otherwise, its name will be replaced with the contents of the line. The pax command will immediately exit 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||Prevent the overwriting of existing files.|
|-l||Link files. In copy mode, hard links will be made between the source and destination file hierarchies whenever possible.|
|-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. |
|-t||Cause the access times of the archived files to be the same as they were before being read by pax.|
|-X||When traversing the file hierarchy specified by a path name, pax will not descend into directories that have a different device ID (st_dev).|
|-w||Write files to the standard output in the specified archive format.|
|-a||Append files to the end of the archive. This option will not work for some archive devices, such as 1/4-inch streaming tapes and 8mm tapes.|
|-f archive||Specify the path name of the input or output archive, overriding the default standard input (in list or read modes) or standard output (write mode).|
|-s replstr||Modify file or archive member names named by pattern or file operands according to the substitution expression replstr, which is based on the ed s (substitution) command, using the regular expression syntax on the regex manual page. The concepts of ``address'' and ``line'' are meaningless in the context of the pax command, and must not be supplied. The format is: |
-s / old/new/ [ gp ]
where, as in ed , old is a basic regular expression and new can contain an ampersand (&) or a \n backreference, where n is a digit. The old string also is permitted to contain newline characters.
Any non-null character can be used as a delimiter ( / shown here). Multiple -s expressions can be specified; the expressions will be applied in the order specified, terminating with the first successful substitution. The optional trailing g is as defined in the ed command. 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.
|- b blocksize||Block the output at a positive decimal integer number of bytes per write to the archive file. Devices and archive formats may impose restrictions on blocking. Blocking is automatically determined on input. Portable applications must not specify a blocksize value larger than 32256. Default blocking when creating archives depends on the archive format. (See the -x option below.)|
|-o options||Reserved for special format-specific options.|
|-p string||Specify one or more file characteristic options (privileges). The string option-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. Multiple characteristics can be concatenated within the same string and multiple -p options can be specified. The meaning of the specification characters are as follows: |
In the preceding list, ``preserve'' indicates that an attribute stored in the archive will be given to the extracted file, subject to the permissions of the invoking process; otherwise, the attribute will be determined as part of the normal file creation action.
If neither the e nor the o specification character is specified, or the user ID and group ID are not preserved for any reason, pax will not set the setuid and setgid bits of the file mode.
If the preservation of any of these items fails for any reason, pax will write a diagnostic message to standard error. Failure to preserve these items will affect the final exit status, but will not cause the extracted file to be deleted.
If file-characteristic letters in any of the string option-arguments are duplicated or conflict
|-x format||Specify the output archive format. The pax command recognizes the following formats: |
|pattern||A pattern matching one or more path names of archive members. A pattern must conform to the pattern matching notation found on the fnmatch manual page. The default, if no pattern is specified, is to select all members in the archive.|
|file||A path name of a file to be copied or archived.|
|directory||The destination directory path name for copy mode.|
pax -w -f /dev/rmt/1m
Copies the contents of the current directory to tape drive 1, medium density.