Pax (command)

pax is an archiving utility available for various operating systems and defined since 1995. Rather than sort out the incompatible options that have crept up between codice_1 and codice_2, along with their implementations across various versions of Unix, the IEEE designed a new archive utility that could support various archive formats with useful options from both archivers. The codice_3 command is available on Unix and Unix-like operating systems and on IBM i, Microsoft Windows NT, and Windows 2000.
IEEE, in 2001, defined a new "pax" format which is basically "tar" with additional extended attributes.
The name "pax" is an acronym for "portable archive exchange". The command invocation and structure is somewhat a unification of both codice_1 and codice_2.
History.
A version of the pax program was created by Keith Muller in 1992–1993. The version first appeared in 4.4BSD (1995). Pax was accepted into X/Open issue 4 (Single Unix Specification version 1) in 1995. These versions of pax only defined the command-line interface as a tar/cpio hybrid, but the pax file format was not yet defined. (The work on defining Pax likely precedes Muller's work; it appears to be in the early POSIX.2 and IEEE 1003.1b drafts circa 1991.)
In 1997, Sun Microsystems proposed a method for adding extensions to the ustar format. This method was later accepted for the POSIX.1-2001 standard, as the new "pax" file format. The POSIX specification for the utility was updated to include this format.
Features.
Modes.
pax has four general modes that are invoked by a combination of the ("read") and ("write") options.
This table summarizes the modal behaviour: 
This model is similar to cpio, which has a similar set of basic operations.
Examples.
List contents of an archive:
Extract contents of an archive into the current directory:
Create an archive of the current directory:
Copy current directory tree to another location:
Command invocation.
By default, it uses the standard input/output for archive and listing operations, but this can be overwridden with the "tar-style" option that specifies the archive file. Pax differs from cpio by recursively considering the content of a directory; to disable this behavior, POSIX pax has an option to disable it.
The command is a mish-mash of and features. Like , processes directory entries recursively, a feature that can be disabled with for cpio-style behavior. The handling of file input/outputs is also a mix: when a list of file names is specified on the command line, they are taken as shell globs for file input or listing (tar-like); otherwise takes the -style behavior of using the standard input for a file list. Finally, supports reading/writing to a named archive file using tar's option.
For example, if one desires a cpio-style archiving of the current directory, can be used with just like one does using cpio:
The command for extracting the contents for an archive is the same as :
It is possible to invoke these commands in a codice_1-like syntax as well:
Compression.
Most implementations of pax use the (gzip) and (bzip2) switches for compression; this feature however, is not specified by POSIX. It is important to note that pax cannot append to compressed archives.
Example for extracting a gzipped archive:
As in tar and cpio, pax output can be piped to another compressor/decompressor program. As an example xz is used here:
and listing an xz-compressed archive as the input:
Format support.
Almost all extant versions of "pax" stemmed from the original 4.4BSD implementation. Most of them inherits the formats supported by that version, selectable via the option:
Notably, the support for the 2001 "pax" format is not supported by this legacy pax. This is the case on most Linux distributions (which uses the MirBSD branch of "MirCPIO-paxmirabilis") and on FreeBSD.
The Heirloom Project pax has support for the "pax" support as well as many extra formats.
Multiple volumes.
pax supports archiving on multiple volumes. When the end of a volume is reached, the following message appears:
$ pax -wf /dev/fd0 .
ATTENTION! pax archive volume change required.
/dev/fd0 ready for archive volume: 2
Load the NEXT STORAGE MEDIA (if required) and make sure it is WRITE ENABLED.
Type "y" to continue, "." to quit pax, or "s" to switch to new device.
If you cannot change storage media, type "s"
Is the device ready and online? >
When restoring an archive from multiple media, pax asks for the next media in the same fashion, when the end of the media is reached before the end of the archive.
Standardization, reception and popularity.
Despite being standardized in 2001 by IEEE, as of 2010, pax enjoys relatively little popularity or adoption. This is in part because there was not any need for it from the Unix users; it was just the POSIX committee that wants to have a more consistent interface. Pax is also fairly chatty and expects user interactions when things go wrong.
pax is required to be present in all conformant systems by Linux Standard Base since version 3.0 (released on July 6, 2005), but so far few Linux distributions ship and install it by default. However, most distributions include pax as a separately installable package.
pax has also been present in Windows NT, where it is limited to file archives (tapes not supported). It was later moved to the Interix subsystem. It does not support archiving or restoring Win32 ACLs.
Packages handled by the Installer (OS X) often carry the bulk of their contents in an Archive.pax.gz file that may be read using the system's pax (heirloom) utility.