On Unix-like operating systems, the pax command reads and writes the contents of archive files, independent of the archive file format.

This page covers the Linux version of pax.

Description

“Pax” is short for “portable archive interchange.” The software support many major archive formats. It can read the contents of each, and write them to a new, single archive.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

Syntax

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] i [-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

Examples

pax -w -f /dev/rmt/1m

Copies the contents of the current directory to tape drive 1, medium density.

-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 ( “/” is shown here). Multiple -s expressions can be specified; the expressions are 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.

In the preceding list, “preserve” indicates 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 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 writes a diagnostic message to standard error. Failure to preserve these items affects 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 with each other, the ones given last takes precedence. For example, if -p eme is specified, file modification times is preserved.

chmod — Change the permissions of files or directories.cpio — Copy files to or from archives.ed — A simple text editor.tar — Create, modify, list the contents of, and extract files from tar archives.