home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

pax

pax [options ] [patterns ]

Solaris only. Portable Archive Exchange program. When members of the POSIX 1003.2 working group could not standardize on either tar or cpio , they invented this program.[1 ] (See also cpio and tar .)

[1] This period in Unix history is known as the "tar wars." :-)

pax operates in four modes, depending on the combinations of -r and -w :

List mode

No -r and no -w . List the contents of a pax archive. Optionally, restrict the output to filenames and/or directories that match a given pattern.

Extract mode

-r only. Extract files from a pax archive. Intermediate directories are created as needed.

Archive mode

-w only. Archive files to a new or existing pax archive. The archive is written to standard output; it may be redirected to an appropriate tape device if needed for backups.

Pass-through mode

-r and -w . Copy a directory tree from one location to another, analogous to cpio -p .

Options

Here are the options available in the four modes:

None:       c d f       n     s     v
-r

:         c d f i k   n o p s   u v
-w

:     a b   d f i       o   s t u v x X
-rw

:          d   i k l n   p s t u v   X

-a

Append files to the archive. This may not work on some tape devices.

-b size

Use size as the blocksize, in bytes, of blocks to be written to the archive.

-c

Complement. Match all file or archive members that do not match the patterns.

-d

For files or archive members that are directories, extract or archive only the directory itself, not the tree it contains.

-f archive

Use archive instead of standard input or standard output.

-i

Interactively rename files. For each file, pax writes a prompt to /dev/tty and reads a one-line response from /dev/tty . The responses are as follows:

Return

Skip the file.

A period

Take the file as is.

new name

Anything else is taken as the new name to use for the file.

EOF

Exit immediately with a nonzero exit status.

-k

Do not overwrite existing files.

-l

Make hard links. When copying a directory tree (-rw ), make hard links between the source and destination hierarchies wherever possible.

-n

Choose the first archive member that matches each pattern. No more than one archive member will match for each pattern.

-o options

Reserved for format-specific options. (Apparently unused in Solaris.)

-p privs

Specify one or more privileges for the extracted file. privs specify permissions or other characteristics to be preserved or ignored.

a

Do not preserve file access times.

e

Retain the user and group IDs, permissions (mode), and access and modification time.

m

Do not preserve the file modification time.

o

Retain the user and group ID.

p

Keep the permissions (mode).

-r

Read an archive and extract files.

-s replacement

Use replacement to modify file or archive member names. This is a string of the form -s/ old / new / [gp ]. This is similar to the substitution commands in ed , ex , and sed . old is a regular expression, and new may contain & to mean the matched text and \ n for subpatterns. The trailing g indicates the substitution should be applied globally. A trailing p causes pax to print the resulting new filename. Multiple -s options may be supplied. The first one that works is applied. Any delimiter may be used, not just / , but in all cases it is wise to quote the argument to prevent the shell from expanding wildcard characters.

-t

Reset the access time of archived files to what they were before being archived by pax .

-u

Ignore files older than preexisting files or archive members. The behavior varies based on the current mode.

Extract mode

Extract the archive file if it is newer than an existing file with the same name.

Archive mode

If an existing file with the same name as an archive member is newer than the archive member, supersede the archive member.

Pass-through mode

Replace the file in the destination hierarchy with the file in the source hierarchy (or a link to it) if the source hierarchy's file is newer.

-v

In list mode, print a verbose table of contents. Otherwise, print archive member names on standard error.

-w

Write files to standard output in the given archive format.

-x format

Use the given format for the archive. The value of format is either cpio or ustar . The details of both formats are provided in the IEEE 1003.1 (1990) POSIX standard. The two formats are mutually incompatible; attempting to append using one format to an archive using the other is an error.

-X

When traversing directory trees, do not cross into a directory on a different device (the st_dev field in the stat structure, see stat (2); similar to the -mount option of find ).

Examples

Copy the current directory to tape:

pax -x ustar -w -f /dev/rmt/0m .

Copy a home directory to a different directory (presumably on a bigger disk).

# cd /home


# pax -r -w arnold /newhome


Previous: Reference: pathchk UNIX in a Nutshell: System V Edition Next: Reference: perl
Reference: pathchk Book Index Reference: perl

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru