Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > P

pax(1)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

pax — extracts, writes, and lists archive files; copies files and directory hierarchies

SYNOPSIS

Listing Member Files of Archived Files

pax [-cdnv] [-H|-L] [-f archive] [-o options]... [-s replstr]... [pattern]...

Extracting Archive Files

pax -r [-cdiknuvy] [-H|-L] [-f archive] [-o options]... [-p string]... [-s replstr]... [pattern]...

Writing Archive Files

pax -w [-adituvXy] [-H|-L] [-b blocking] [-f archive] [-o options]... [-s replstr]... [-x format] [file]...

Copying Files

pax -r -w [-diklntuvXy] [-H|-L] [-o options]... [-p string]... [-s replstr]... [file]... directory

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).

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.

pax also reads and writes archives in the pax interchange format, IEEE Std 1003.1, 2003 Edition. Use the -x pax flag to specify this format. Refer to the description of the -x format option for more details.

The supported archive formats are automatically detected on input. All three formats are explained in greater detail under EXTENDED DESCRIPTION.

The four combinations of -r and -w are referred to as the four modes of operation: list, read, write, and copy modes, corresponding respectively to the four forms shown in the SYNOPSIS section.

list

In list mode (when neither -r nor -w are specified), pax shall write 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 that file shall be listed as well.

read

In read mode (when -r is specified, but -w is not), pax shall extract 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 shall be extracted as well. The extracted files shall be created performing pathname resolution with the directory in which pax was invoked as the current working directory.

If an attempt is made to extract a directory when the directory already exists, this shall not be considered an error. If an attempt is made to extract a FIFO when the FIFO already exists, this shall not be considered an error.

write

In write mode (when -w is specified, but -r is not), pax shall write 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, shall be read from the standard input. A file of type directory shall include all of the files in the file hierarchy rooted at the file.

copy

In copy mode (when both -r and -w are specified), pax shall copy the file operands to the destination directory.

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

The effect of the copy shall be 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. If the destination directory is a subdirectory of one of the files to be copied, the results are unspecified. It shall be 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 shall perform actions equivalent to the mkdir() function defined in the System Interfaces volume of IEEE Std 1003.1-2001, called with the following arguments:

1.

The intermediate directory used as the path argument

2.

The value of the bitwise-inclusive OR of S_IRWXU, S_IRWXG, and S_IRWXO as the mode argument

If the selected archive format supports the specification of linked files, it shall be an error if these files cannot be linked when the archive is extracted, except that if the files to be linked are symbolic links then separate copies of the symbolic link shall be created instead. For archive formats that do not store file contents with each name that causes a hard link, if the file that contains the data is not extracted during this pax session, a diagnostic message shall be displayed with the name of a file that can be used to extract the data.

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.

-H

If a symbolic link referencing a file of type directory is specified on the command line, pax shall archive the file hierarchy rooted in the file referenced by the link, using the name of the link as the root of the file hierarchy. Otherwise, if a symbolic link referencing a file of any other file type which pax can normally archive is specified on the command line, then pax shall archive the file referenced by the link, using the name of the link. The default behavior shall be to archive the symbolic link itself.

-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.

-L

If a symbolic link referencing a file of type directory is specified on the command line or encountered during the traversal of a file hierarchy, pax shall archive the file hierarchy rooted in the file referenced by the link, using the name of the link as the root of the file hierarchy. Otherwise, if a symbolic link referencing a file of any other file type which pax can normally archive is specified on the command line or encountered during the traversal of a file hierarchy, pax shall archive the file referenced by the link, using the name of the link. The default behavior shall be to archive the symbolic link itself.

-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).

-o options

Provides information to the implementation to modify the algorithm for extracting or writing files. The value of options shall consist of one or more comma-separated keywords of the form:

keyword[[:]=value][,keyword[[:]=value, ]...]

Some keywords apply only to certain file formats, as indicated with each description. Use of keywords that are inapplicable to the file format being processed causes pax to print an error message and ignore the keyword. However pax will continue processing the archive. Keywords in the options argument shall be a string that would be a valid portable filename as described in the Base Definitions volume of IEEE Std 1003.1-2001, Section 3.276, Portable Filename Character Set.

Note: Keywords are not expected to be filenames, merely to follow the same character composition rules as portable filenames.

The value field shall consist of zero or more characters; within value, the application shall precede any literal comma with a backslash, which shall be ignored, but preserves the comma as part of value. A comma as the final character, or a comma followed solely by white space as the final characters, in options shall be ignored. Multiple -o options can be specified; if keywords given to these multiple -o options conflict, the keywords and values appearing later in command line sequence shall take precedence and the earlier shall be silently ignored. Also, if the value specified for a keyword is invalid, pax shall print a suitable error message and behave as if the keyword were not specified in the command line. The following keyword values of options shall be supported for the file formats as indicated:

delete=pattern

(Applicable only to the -x pax format.) When used in write or copy mode, pax shall omit from extended header records that it produces any keywords matching the string pattern. When used in read or list mode, pax shall ignore any keywords matching the string pattern in the extended header records. In both cases, matching shall be performed using the pattern matching notation described in Patterns Matching a Single Character and Patterns Matching Multiple Characters. For example, the following pattern:

-o delete=[ug]name

would suppress user and group name keywords in the extended header.

See pax Extended Header for extended header record keyword usage. When multiple -o delete=pattern options are specified, the patterns shall be additive; all keywords matching the specified string patterns shall be omitted from extended header records that pax produces.

exthdr.name=string

(Applicable only to the -x pax format.) This keyword allows user control over the name that is written into the ustar header blocks for the extended header produced under the circumstances described in pax Header Block. The name shall be the contents of string, after the following character substitutions have been made:

%d

The directory name of the file, equivalent to the result of the dirname utility on the translated pathname.

%f

The filename of the file, equivalent to the result of the basename utility on the translated pathname.

%p

The process ID of the pax process.

%%

A '%' character.

If there are any other '%' characters in string, or if no -o exthdr.name=string is specified, pax shall use the following default value:

%d/PaxHeaders.%p/%f

globexthdr.name=string

(Applicable only to the -x pax format.) This keyword allows user control over the name that is written into the ustar header blocks for global extended header records. The name shall be the contents of string, after the following character substitutions have been made:

%n

An integer that represents the sequence number of the global extended header record in the archive, starting at 1.

%p

The process ID of the pax process.

%%

A '%' character.

If there are any other '%' characters in string, or if no -o globexthdr.name=string is specified, pax shall use the following default value:

$TMPDIR/GlobalHead.%p.%n

where $TMPDIR represents the value of the TMPDIR environment variable. If TMPDIR is not set, pax shall use /tmp.

invalid=action

(Applicable only to the -x pax format.) This keyword allows user control over the action pax takes upon encountering values in an extended header record that, in read or copy mode, are invalid in the destination hierarchy. The following are invalid values that shall be recognized by pax: In read or copy mode, a filename or link name that is longer than the maximum allowed in the destination hierarchy.

The following mutually-exclusive values of the action argument are supported:

bypass

In read or copy mode, pax shall bypass the file, causing no change to the destination hierarchy.

rename

In read or copy mode, pax shall act as if the -i option were in effect for each file with invalid filename or link name values, allowing the user to provide a replacement name interactively.

write

In read or copy mode, pax shall write the file, translating the name regardless of whether this may overwrite an existing file with a valid name. This action argument is not supported for files having invalid link names.

If no -o invalid= option is specified, pax shall act as if -o invalid=bypass was specified. Any overwriting of existing files that may be allowed by the -o invalid= actions shall be subject to permission (-p) and modification time (-u) restrictions, and shall be suppressed if the -k option is also specified.

linkdata

(Applicable only to the -x pax format.) In write mode, pax shall write the contents of a file to the archive even when that file is merely a hard link to a file whose contents have already been written to the archive.

listopt=format

This keyword specifies the output format of the table of contents produced when the -v option is specified in list mode. See List Mode Format Specifications. To avoid ambiguity, the listopt= format shall be the only or final keyword= value pair in a -o option-argument; all characters in the remainder of the option-argument shall be considered part of the format string. When multiple -o listopt=format options are specified, the format strings shall be considered a single, concatenated string, evaluated in command line order.

times

(Applicable only to the -x pax format.) When used in write or copy mode, pax shall include atime and mtime extended header records for each file. See pax Extended Header File Times.

In addition to these keywords, if the -x pax format is specified, any of the keywords and values defined in pax Extended Header can be used in -o option-arguments, in either of two modes:

keyword=value

When used in write or copy mode, these keyword/value pairs shall be included at the beginning of the archive as typeflag g global extended header records. When used in read or list mode, these keyword/value pairs shall act as if they had been at the beginning of the archive as typeflag g global extended header records.

keyword:=value

When used in write or copy mode, these keyword/value pairs shall be included as records at the beginning of a typeflag x extended header for each file. (This shall be equivalent to the equal-sign form except that it creates no typeflag g global extended header records.) When used in read or list mode, these keyword/value pairs shall act as if they were included as records at the end of each extended header; thus, they shall override any global or file-specific extended header record keywords of the same names. For example, in the command below, the group name will be forced to a new value for all files read from the archive:

pax -r -o" gname:=mygroup, " <archive

The precedence of -o keywords over various fields in the archive is described in pax Extended Header Keyword Precedence.

-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 shall 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]

whereas 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 non-null 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.

pax

The pax interchange format. See IEEE Std 1003.1, 2003 Edition. The default block size for this format for character special archive files shall be 5120. Blocking values from 512 to 32,256 in increments of 512 are supported.

This is an extended ustar format. The pax format should be used for archiving and extracting files having one or more of the following properties: size 8GB or more, UID or GID greater than 2097151, user or group names longer than 31 characters, pathname longer than 256 characters or link name longer than 100 characters. Archives of this format are reported as "USTAR format archive extended" in the read and list mode when the -v (verbose) flag is specified in the command line.

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

Specifying more than one of the mutually-exclusive options -H and -L shall not be considered an error and the last option specified shall determine the behavior of the utility.

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.

Listing Member Files of Archived Files

You can specify the pax command without the -r or -w flags with the -H or -L, -c, -d, -f, -n, -o, -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.

If the -v flag is specified, the listing is output in the ls -l command format. In the verbose listing pax lists hard link pathnames as follows:

pathname==linkname

pax lists symbolic link pathnames as follows:

pathname->linkname

In the case of hard links, 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.

Extracting Archive Files

The -r flag can be specified with the -H or -L, -c, -d, -f, -n, -o, -s, and -v flags, and a pattern argument.

Writing Archive Files

The -w flag can be specified with the -H or -L, -b, -d, -f, -i, -o, -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

The -r and -w flags can be specified with the -H or -L, -d, -i, -k, -l, -o, -p, -n, -s, -t, -u, -v, and -X flags and with the file arguments. A directory argument must be specified.

List Mode Format Specifications

In list mode with the -o listopt= format option, the format argument shall be applied for each selected file. The pax utility shall append a newline to the listopt output for each selected file. The format argument shall be used as the format string described in the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 5, File Format Notation, with the exceptions 1. through 5. defined in the EXTENDED DESCRIPTION section of printf, plus the following exceptions:

1. through 5.

Defined in the EXTENDED DESCRIPTION section of printf.

6.

The sequence (keyword) can occur before a format conversion specifier. The conversion argument is defined by the value of keyword. The implementation shall support the following keywords:

  • Any of the Field Name entries in ustar Header Block and Octet-Oriented cpio Archive Entry.

  • Any keyword defined for the extended header in pax Extended Header.

    For example, the sequence "%(charset)s" is the string value of the name of the character set in the extended header. Refer to the section EXTENDED DESCRIPTION for the list of keywords in each format.

    The result of the keyword conversion argument shall be the value from the applicable header field or extended header, without any trailing NULL characters.

7.

An additional conversion specifier character, T, shall be used to specify time formats. The T conversion specifier character can be preceded by the (keyword=subformat) sequence where subformat is a date format as defined by date operands. The default keyword shall be mtime and the default subformat shall be:

%b %e %H:%M %Y

8.

An additional conversion specifier character, M, shall be used to specify the file mode string as defined in ls Standard Output. If (keyword) is omitted, the mode keyword shall be used. For example, %.1M writes the single character corresponding to the entry_type field of the ls -l command

9.

An additional conversion specifier character, D, shall be used to specify the device for block or special files, if applicable. If not applicable, and (keyword) is specified, then this conversion shall be equivalent to %(keyword)u. If not applicable, and (keyword) is omitted, then this conversion shall be equivalent to space.

10.

An additional conversion specifier character, F, shall be used to specify a pathname. The F conversion character can be preceded by a sequence of comma-separated keywords:

(keyword[,keyword] ...)

The values for all the keywords that are non-null shall be concatenated together, each separated by a '/'. The default shall be (path) if the keyword path is defined; otherwise, the default shall be (prefix,name).

11.

An additional conversion specifier character, L, shall be used to specify a symbolic line expansion. If the current file is a symbolic link, then %L shall expand to:

%s -> %s, value_of_keyword, contents_of_link

Otherwise, the %L conversion specification shall be the equivalent of %F.

EXTENDED DESCRIPTION

cpio Interchange Format

The octet-oriented cpio archive format shall be a series of entries, each comprising a header that describes the file, the name of the file, and then the contents of the file. The fields of the cpio header are described below:

c_magic

Identify the archive as being a transportable archive by containing the identifying value "070707".

c_dev,c_ino

Contains values that uniquely identify the file within the archive. No files contain the same pair of c_dev and c_ino values unless they are links to the same file.

c_mode

Contains the file type and access permissions.

c_uid

Contains the user ID of the owner of the file.

c_gid

Contains the group ID of the group owner of the file.

c_nlink

Contains the number links of the file.

c_rdev

Contains information for character or block special files.

c_mtime

Contains the latest time of modification of the file at the time the archive was created.

c_namesize

Contains the length of the pathname, including the terminating NUL character.

c_filesize

Contains the length of the file in bytes. This shall be the length of the data section following the header structure.

ustar Interchange Format

A ustar archive tape or file shall contain a series of logical records. Each logical record shall be a fixed-size logical record of 512 bytes. Each file archived shall be represented by a header logical record that describes the file, followed by zero or more logical records that give the contents of the file. At the end of the archive file there shall be two 512-octet logical records filled with binary zeros, interpreted as an end-of-archive indicator. The header logical record shall contain the following fields:

name,prefix

The name and the prefix fields shall produce the pathname of the file. A new pathname shall be formed, if prefix is not an empty string (its first character is not NUL), by concatenating prefix (up to the first NUL character), a slash character, and name; otherwise, name is used alone. In this manner, pathnames up to 256 characters can be supported. If a pathname does not fit in the space provided, pax shall notify the user of the error, and shall not store any part of the file-header or data on the medium.

mode

The mode field provides 12 bits encoded in the ISO/IEC 646:1991 standard octal digit representation to encode the permissions.

uid,gid

The user and group ID of the owner and group of the file, respectively. If uid or gid is greater than 2097151, a value of -1 will be stored in the respective field of the ustar header. If the corresponding name (user name for uid and group name for gid) also could not be stored in the archive, pax shall notify the user of the error but shall include the other attributes of the file and its data on the medium.

uname,gname

The names of the owner and group of the file, respectively. If the user or group name is longer than 31 characters, it will not be stored in the respective field of the ustar header. pax shall notify the user of the error but shall include the other attributes of the file and its data on the medium.

size

The size of the file in bytes. If the size of the files is greater than or equal to 8GB, pax shall notify the user of the error, and shall not store any part of the file-header or data on the medium.

mtime

The modification time of the file at the time it was archived.

typeflag

Specifies the type of file archived. All of the typeflag fields shall be coded in the ISO/IEC 646:1991 standard IRV

0

Represents a regular file.

1

Represents a file linked to another file, of any type, previously archived. The linked-to name is specified in the linkname field with a NUL-character terminator if it is less than 100 bytes in length.

2

Represents a symbolic link. The contents of the symbolic link shall be stored in the linkname field.

3,4

Represents character special files and block special files respectively.

5

Specifies a directory or subdirectory.

6

Specifies a FIFO special file. Note that the archiving of a FIFO file archives the existence of this file and not its contents.

linkname

The linkname is the pathname of the target of a symbolic or hard link. It is limited to 100 characters. If the name does not fit in the space provided, pax shall notify the user of the error, and shall not attempt to store the link on the medium.

devmajor,devminor

When the typeflag field contains '3' or '4' the devmajor and devminor fields shall contain the major and minor numbers of the device respectively.

chksum

The octal value of the simple sum of all bytes in the header logical record. Each bytes in the header shall be treated as an unsigned value. When calculating the checksum, the chksum field is treated as if it were all spaces.

magic

The magic field is the specification that this archive was output in this archive format. If this field contains ustar (the five characters from the ISO/IEC 646:1991 standard IRV shown followed by NUL), the uname and gname fields shall contain the ISO/IEC 646:1991 standard IRV representation of the owner and group of the file, respectively. When the file is restored by a privileged, protection-preserving version of the utility, the user and group databases shall be scanned for these names. If found, the user and group IDs contained within these files shall be used rather than the values contained within the uid and gid fields.

version

The version field is two bytes containing the characters "00" (zero-zero).

pax Interchange Format

A pax archive tape or file produced in the -x pax format shall contain a series of blocks. The physical layout of the archive shall be identical to the ustar format described in ustar Interchange Format. Each file archived shall be represented by the following sequence:

1.

An optional header block with extended header records. This header is of the form described in pax Header Block with a typeflag value of x or g. The extended header records, described in pax Extended Header shall be included as the data for this header block.

2.

A header block that describes the file. Any fields in the preceding optional extended header shall override the associated fields in this header block for this file.

3.

Zero or more blocks that contain the contents of the file.

At the end of the archive file there shall be two 512-byte blocks filled with binary zeros, interpreted as an end-of-archive indicator.

pax Header Block

The pax header block shall be identical to the ustar header block described in ustar Interchange Format except that two additional typeflag values are defined:

x

Represents extended header records for the following file in the archive (which shall have its own ustar header block). The format of these extended header records shall be as described in the pax Extended Header section of this manpage.

g

Represents global extended header records for the following files in the archive. The format of these extended header records shall be as described in pax Extended Header. Each value shall affect all subsequent files that do not override that value in their own extended header record and until another global extended header record is reached that provides another value for the same field. The typeflag g global headers should not be used with interchange media that could suffer partial data loss in transporting the archive.

For both of these types, the size field shall be the size of the extended header records in bytes. The other fields in the header block are not meaningful to this version of the pax utility.

A further difference from the ustar header block is that data blocks for files of typeflag 1 (the digit one) (hard link) may be included, which means that the size field may be greater than zero. Archives created by pax -o linkdata shall include these data blocks with the hard links.

pax Extended Header

A pax extended header contains values that are inappropriate for the ustar header block because of limitations in that format: fields representing file attributes not described in the ustar header, and fields whose format or length do not fit the requirements of the ustar header. The values in an extended header add attributes to the following file (or files; see the description of the typeflag g header block) or override values in the following header block(s), as indicated in the following list of keywords.

An extended header shall consist of one or more records, each constructed as follows:

%d %s=%s\n,length,keyword,value

The keyword field shall be one of the entries from the following list. A keyword shall not include an equals sign. In the following list, the notations "file(s)" or "block(s)" are used to acknowledge that a keyword affects the following single file after a typeflag x extended header, but possibly multiple files after typeflag g. Any requirements in the list for pax to include a record when in write or copy mode shall apply only when such a record has not already been provided through the use of the -o option. When used in copy mode, pax shall behave as if an archive had been created with applicable extended header records and then extracted.

atime

The file access time for the following file(s), equivalent to the value of the st_atime member of the stat structure for a file, as described by the stat() function. The format of the value shall be as described in pax Extended Header File Times.

comment

A series of characters used as a comment. All characters in the value field shall be ignored by pax.

gid

The group ID of the group that owns the file, expressed as a decimal number using digits from the ISO/IEC 646:1991 standard. This record shall override the gid field in the following header block(s). When used in write or copy mode, pax shall include a gid extended header record for each file whose group ID is greater than 2097151 (octal 7777777).

gname

The group of the file(s), formatted as a group name in the group database. This record shall override the gid and gname fields in the following header block(s), and any gid extended header record. When used in write or copy mode, pax shall include a gname extended header record for each file whose group name cannot be represented in the ustar header.

linkpath

The pathname of a link being created to another file, of any type, previously archived. This record shall override the linkname field in the following ustar header block(s). The following ustar header block shall determine the type of link created. If typeflag of the following header block is 1, it shall be a hard link. If typeflag is 2, it shall be a symbolic link and the linkpath value shall be the contents of the symbolic link. When used in write or copy mode, pax shall include a linkpath extended header record for each link whose pathname cannot be represented in the ustar header.

mtime

The file modification time of the following file(s), equivalent to the value of the st_mtime member of the stat structure for a file, as described in the stat() function. This record shall override the mtime field in the following header block(s). The modification time shall be restored if the process has the appropriate privilege required to do so. The format of the value is described in pax Extended Header File Times.

path

The pathname of the following file(s). This record shall override the name and prefix fields in the following header block(s). When used in write or copy mode, pax shall include a path extended header record for each file whose pathname cannot be represented entirely in the ustar header.

size

The size of the file in bytes, expressed as a decimal number using digits from the ISO/IEC 646:1991 standard. This record shall override the size field in the following header block(s). When used in write or copy mode, pax shall include a size extended header record for each file with a size value greater than 8589934591 (octal 77777777777).

uid

The user ID of the file owner, expressed as a decimal number using digits from the ISO/IEC 646:1991 standard. This record shall override the uid field in the following header block(s). When used in write or copy mode, pax shall include a uid extended header record for each file whose owner ID is greater than 2097151 (octal 7777777).

uname

The owner of the following file(s), formatted as a user name in the user database. This record shall override the uid and uname fields in the following header block(s), and any uid extended header record. When used in write or copy mode, pax shall include a uname extended header record for each file whose user name cannot be represented entirely in the ustar header.

If the value field is zero length, it shall delete any header block field, previously entered extended header value, or global extended header value of the same name.

If a keyword in an extended header record (or in a -o option-argument) overrides or deletes a corresponding field in the ustar header block, pax shall ignore the contents of that header block field.

Unlike the ustar header block fields, NULs shall not delimit values; all characters within the value field shall be considered data for the field. None of the length limitations of the ustar header block fields in ustar Header Block shall apply to the extended header records.

pax Extended Header Keyword Precedence

This section describes the precedence in which the various header records and fields and command line options are selected to apply to a file in the archive. When pax is used in read or list modes, it shall determine a file attribute in the following sequence:

1.

If -o delete= keyword-prefix is used, the affected attributes shall be determined from Step 7., if applicable, or ignored otherwise.

2.

If -o keyword:= is used, the affected attributes shall be ignored.

3.

If -o keyword:=value is used, the affected attribute shall be assigned the value.

4.

If there is a typeflag x extended header record, the affected attribute shall be assigned the value. When extended header records conflict, the last one given in the header shall take precedence.

5.

If -o keyword=value is used, the affected attribute shall be assigned the value.

6.

If there is a typeflag g global extended header record, the affected attribute shall be assigned the value. When global extended header records conflict, the last one given in the global header shall take precedence.

7.

Otherwise, the attribute shall be determined from the ustar header block.

pax Extended Header File Times

The pax utility shall write an mtime record for each file in write or copy modes if the file's modification time cannot be represented exactly in the ustar header logical record described in ustar Interchange Format. This can occur if the time is out of ustar range, or if the file system of the underlying implementation supports non-integer time granularities and the time is not an integer. All of these time records shall be formatted as a decimal representation of the time in seconds since the Epoch. If a period ( '.' ) decimal point character is present, the digits to the right of the point shall represent the units of a sub second timing granularity, where the first digit is tenths of a second and each subsequent digit is a tenth of the previous digit.

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/rtape/tape4QIC150 .

To copy the olddir directory hierarchy to newdir enter:

mkdir newdir 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 * tar xfv - < archive pax -rv < archive (cd /fromdir; tar cf - . ) | (cd /todir; tar xf -) pax -rw /fromdir /todir

Note: 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 of size 8GB or larger for both ustar and cpio formats. Also, pax does not support user and group IDs greater than or equal to 2048K for ustar format. pax does not support and user and group IDs greater than or equal to 256K for cpio format. With ustar format, files with user IDs greater than or equal to 2048K are restored under the user ID of the current process, unless the user name exists. The same applies for group IDs. In cpio format, files with user or group IDs greater than or equal to 256K will not be recovered with the original user or group IDs respectively.

AUTHOR

pax was developed by Mark H. Colburn, OSF, and HP.

STANDARDS CONFORMANCE

pax: XPG4, POSIX.2

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.