1PAX(1)                    BSD General Commands Manual                   PAX(1)
2

NAME

4     pax — read and write file archives and copy directory hierarchies
5

SYNOPSIS

7     pax [-0cdOnvz] [-f archive] [-s replstr] ... [-U user] ... [-G group] ...
8         [-T [from_date] [,to_date]] ... [pattern ...]
9     pax -r [-cdiknuvzDOYZ] [-f archive] [-o options] ... [-p string] ...
10         [-s replstr] ... [-E limit] [-U user] ... [-G group] ... [-T
11         [from_date] [,to_date]] ... [pattern ...]
12     pax -w [-0dituvzHLOPX] [-b blocksize] [[-a] [-f archive]] [-x format]
13         [-s replstr] ... [-o options] ... [-U user] ... [-G group] ...
14         [-B bytes] [-T [from_date] [,to_date] [/[c][m]]] ... [file ...]
15     pax -r -w [-0diklntuvDHLOPXYZ] [-p string] ... [-s replstr] ... [-U user]
16         ... [-G group] ... [-T [from_date] [,to_date] [/[c][m]]] ...
17         [file ...] directory
18

DESCRIPTION

20     pax will read, write, and list the members of an archive file, and will
21     copy directory hierarchies.  pax operation is independent of the specific
22     archive format, and supports a wide variety of different archive formats.
23     A list of supported archive formats can be found under the description of
24     the -x option.
25
26     The presence of the -r and the -w options specifies which of the follow‐
27     ing functional modes pax will operate under: list, read, write, and copy.
28
29     <none>  List.  pax will write to standard output a table of contents of
30             the members of the archive file read from standard input, whose
31             pathnames match the specified patterns.  The table of contents
32             contains one filename per line and is written using single line
33             buffering.
34
35     -r      Read.  pax extracts the members of the archive file read from the
36             standard input, with pathnames matching the specified patterns.
37             The archive format and blocking is automatically determined on
38             input.  When an extracted file is a directory, the entire file
39             hierarchy rooted at that directory is extracted.  All extracted
40             files are created relative to the current file hierarchy.  The
41             setting of ownership, access and modification times, and file
42             mode of the extracted files are discussed in more detail under
43             the -p option.
44
45     -w      Write.  pax writes an archive containing the file operands to
46             standard output using the specified archive format.  When no file
47             operands are specified, a list of files to copy with one per line
48             is read from standard input.  When a file operand is also a
49             directory, the entire file hierarchy rooted at that directory
50             will be included.
51
52     -r -w   Copy.  pax copies the file operands to the destination directory.
53             When no file operands are specified, a list of files to copy with
54             one per line is read from the standard input.  When a file oper‐
55             and is also a directory the entire file hierarchy rooted at that
56             directory will be included.  The effect of the copy is as if the
57             copied files were written to an archive file and then subse‐
58             quently extracted, except that there may be hard links between
59             the original and the copied files (see the -l option below).
60
61             Warning: The destination directory must not be one of the file
62             operands or a member of a file hierarchy rooted at one of the
63             file operands.  The result of a copy under these conditions is
64             unpredictable.
65
66     While processing a damaged archive during a read or list operation, pax
67     will attempt to recover from media defects and will search through the
68     archive to locate and process the largest number of archive members pos‐
69     sible (see the -E option for more details on error handling).
70
71     The directory operand specifies a destination directory pathname.  If the
72     directory operand does not exist, or it is not writable by the user, or
73     it is not of type directory, pax will exit with a non-zero exit status.
74
75     The pattern operand is used to select one or more pathnames of archive
76     members.  Archive members are selected using the pattern matching nota‐
77     tion described by fnmatch(3).  When the pattern operand is not supplied,
78     all members of the archive will be selected.  When a pattern matches a
79     directory, the entire file hierarchy rooted at that directory will be
80     selected.  When a pattern operand does not select at least one archive
81     member, pax will write these pattern operands in a diagnostic message to
82     standard error and then exit with a non-zero exit status.
83
84     The file operand specifies the pathname of a file to be copied or
85     archived.  When a file operand does not select at least one archive mem‐
86     ber, pax will write these file operand pathnames in a diagnostic message
87     to standard error and then exit with a non-zero exit status.
88
89     The options are as follows:
90
91     -r      Read an archive file from standard input and extract the speci‐
92             fied files.  If any intermediate directories are needed in order
93             to extract an archive member, these directories will be created
94             as if mkdir(2) was called with the bitwise inclusive OR of
95             S_IRWXU, S_IRWXG, and S_IRWXO as the mode argument.  When the
96             selected archive format supports the specification of linked
97             files and these files cannot be linked while the archive is being
98             extracted, pax will write a diagnostic message to standard error
99             and exit with a non-zero exit status at the completion of opera‐
100             tion.
101
102     -w      Write files to the standard output in the specified archive for‐
103             mat.  When no file operands are specified, standard input is read
104             for a list of pathnames with one per line without any leading or
105             trailing ⟨blanks⟩.
106
107     -a      Append files to the end of an archive that was previously writ‐
108             ten.  If an archive format is not specified with a -x option, the
109             format currently being used in the archive will be selected.  Any
110             attempt to append to an archive in a format different from the
111             format already used in the archive will cause pax to exit immedi‐
112             ately with a non-zero exit status.  The blocking size used in the
113             archive volume where writing starts will continue to be used for
114             the remainder of that archive volume.
115
116             Warning: Many storage devices are not able to support the opera‐
117             tions necessary to perform an append operation.  Any attempt to
118             append to an archive stored on such a device may damage the ar‐
119             chive or have other unpredictable results.  Tape drives in par‐
120             ticular are more likely to not support an append operation.  An
121             archive stored in a regular file system file or on a disk device
122             will usually support an append operation.
123
124     -0      Use the NUL (‘\0’) character as a pathname terminator, instead of
125             newline (‘\n’).  This applies only to the pathnames read from
126             standard input in the write and copy modes, and to the pathnames
127             written to standard output in list mode.  This option is expected
128             to be used in concert with the -print0 function in find(1) or the
129             -0 flag in xargs(1).
130
131     -b blocksize
132             When writing an archive, block the output at a positive decimal
133             integer number of bytes per write to the archive file.  The
134             blocksize must be a multiple of 512 bytes with a maximum of 64512
135             bytes.  Archives larger than 32256 bytes violate the POSIX stan‐
136             dard and will not be portable to all systems.  A blocksize can
137             end with ‘k’ or ‘b’ to specify multiplication by 1024 (1K) or
138             512, respectively.  A pair of blocksizes can be separated by ‘x’
139             to indicate a product.  A specific archive device may impose
140             additional restrictions on the size of blocking it will support.
141             When blocking is not specified, the default blocksize is depen‐
142             dent on the specific archive format being used (see the -x
143             option).
144
145     -c      Match all file or archive members except those specified by the
146             pattern and file operands.
147
148     -d      Cause files of type directory being copied or archived, or ar‐
149             chive members of type directory being extracted, to match only
150             the directory file or archive member and not the file hierarchy
151             rooted at the directory.
152
153     -f archive
154             Specify archive as the pathname of the input or output archive,
155             overriding the default standard input (for list and read) or
156             standard output (for write).  A single archive may span multiple
157             files and different archive devices.  When required, pax will
158             prompt for the pathname of the file or device of the next volume
159             in the archive.
160
161     -i      Interactively rename files or archive members.  For each archive
162             member matching a pattern operand or each file matching a file
163             operand, pax will prompt to /dev/tty giving the name of the file,
164             its file mode, and its modification time.  pax will then read a
165             line from /dev/tty.  If this line is blank, the file or archive
166             member is skipped.  If this line consists of a single period, the
167             file or archive member is processed with no modification to its
168             name.  Otherwise, its name is replaced with the contents of the
169             line.  pax will immediately exit with a non-zero exit status if
170             EOF is encountered when reading a response or if /dev/tty cannot
171             be opened for reading and writing.
172
173     -k      Do not overwrite existing files.
174
175     -l      (The lowercase letter “ell.”) Link files.  In the copy mode (-r
176             -w), hard links are made between the source and destination file
177             hierarchies whenever possible.
178
179     -n      Select the first archive member that matches each pattern oper‐
180             and.  No more than one archive member is matched for each
181             pattern.  When members of type directory are matched, the file
182             hierarchy rooted at that directory is also matched (unless -d is
183             also specified).
184
185     -o options
186             Information to modify the algorithm for extracting or writing ar‐
187             chive files which is specific to the archive format specified by
188             -x.  In general, options take the form: name=value.
189
190     -p string
191             Specify one or more file characteristic options (privileges).
192             The string option-argument is a string specifying file character‐
193             istics to be retained or discarded on extraction.  The string
194             consists of the specification characters a, e, m, o, and p.  Mul‐
195             tiple characteristics can be concatenated within the same string
196             and multiple -p options can be specified.  The meaning of the
197             specification characters are as follows:
198
199             a   Do not preserve file access times.  By default, file access
200                 times are preserved whenever possible.
201
202             e   ‘Preserve everything’, the user ID, group ID, file mode bits,
203                 file access time, and file modification time.  This is
204                 intended to be used by root, someone with all the appropriate
205                 privileges, in order to preserve all aspects of the files as
206                 they are recorded in the archive.  The e flag is the sum of
207                 the o and p flags.
208
209             m   Do not preserve file modification times.  By default, file
210                 modification times are preserved whenever possible.
211
212             o   Preserve the user ID and group ID.
213
214             p   ‘Preserve’ the file mode bits.  This is intended to be used
215                 by a user with regular privileges who wants to preserve all
216                 aspects of the file other than the ownership.  The file times
217                 are preserved by default, but two other flags are offered to
218                 disable this and use the time of extraction instead.
219
220             In the preceding list, ‘preserve’ indicates that an attribute
221             stored in the archive is given to the extracted file, subject to
222             the permissions of the invoking process.  Otherwise the attribute
223             of the extracted file is determined as part of the normal file
224             creation action.  If neither the e nor the o specification char‐
225             acter is specified, or the user ID and group ID are not preserved
226             for any reason, pax will not set the S_ISUID (setuid) and S_ISGID
227             (setgid) bits of the file mode.  If the preservation of any of
228             these items fails for any reason, pax will write a diagnostic
229             message to standard error.  Failure to preserve these items will
230             affect the final exit status, but will not cause the extracted
231             file to be deleted.  If the file characteristic letters in any of
232             the string option-arguments are duplicated or conflict with each
233             other, the one(s) given last will take precedence.  For example,
234             if
235                   -p eme
236             is specified, file modification times are still preserved.
237
238     -s replstr
239             Modify the file or archive member names specified by the pattern
240             or file operands according to the substitution expression
241             replstr, using the syntax of the ed(1) utility regular expres‐
242             sions.  The format of these regular expressions are:
243                   /old/new/[gp]
244             As in ed(1), old is a basic regular expression and new can con‐
245             tain an ampersand (‘&’), ‘\n’ (where n is a digit) back-refer‐
246             ences, or subexpression matching.  The old string may also con‐
247             tain newline characters.  Any non-null character can be used as a
248             delimiter (‘/’ is shown here).  Multiple -s expressions can be
249             specified.  The expressions are applied in the order they are
250             specified on the command line, terminating with the first suc‐
251             cessful substitution.  The optional trailing g continues to apply
252             the substitution expression to the pathname substring which
253             starts with the first character following the end of the last
254             successful substitution.  The first unsuccessful substitution
255             stops the operation of the g option.  The optional trailing p
256             will cause the final result of a successful substitution to be
257             written to standard error in the following format:
258                   <original pathname> >> <new pathname>
259             File or archive member names that substitute to the empty string
260             are not selected and will be skipped.
261
262     -t      Reset the access times of any file or directory read or accessed
263             by pax to be the same as they were before being read or accessed
264             by pax.
265
266     -u      Ignore files that are older (having a less recent file modifica‐
267             tion time) than a pre-existing file or archive member with the
268             same name.  During read, an archive member with the same name as
269             a file in the file system will be extracted if the archive member
270             is newer than the file.  During write, a file system member with
271             the same name as an archive member will be written to the archive
272             if it is newer than the archive member.  During copy, the file in
273             the destination hierarchy is replaced by the file in the source
274             hierarchy or by a link to the file in the source hierarchy if the
275             file in the source hierarchy is newer.
276
277     -v      During a list operation, produce a verbose table of contents
278             using the format of the ls(1) utility with the -l option.  For
279             pathnames representing a hard link to a previous member of the
280             archive, the output has the format:
281                   <ls -l listing> == <link name>
282             For pathnames representing a symbolic link, the output has the
283             format:
284                   <ls -l listing> => <link name>
285             Where <ls -l listing> is the output format specified by the ls(1)
286             utility when used with the -l option.  Otherwise for all the
287             other operational modes (read, write, and copy), pathnames are
288             written and flushed to standard error without a trailing newline
289             as soon as processing begins on that file or archive member.  The
290             trailing newline is not buffered and is written only after the
291             file has been read or written.
292
293     -x format
294             Specify the output archive format, with the default format being
295             ustar.  pax currently supports the following formats:
296
297             cpio     The extended cpio interchange format specified in the
298                      IEEE Std 1003.2 (“POSIX.2”) standard.  The default
299                      blocksize for this format is 5120 bytes.  Inode and
300                      device information about a file (used for detecting file
301                      hard links by this format) which may be truncated by
302                      this format is detected by pax and is repaired.
303
304             bcpio    The old binary cpio format.  The default blocksize for
305                      this format is 5120 bytes.  This format is not very por‐
306                      table and should not be used when other formats are
307                      available.  Inode and device information about a file
308                      (used for detecting file hard links by this format)
309                      which may be truncated by this format is detected by pax
310                      and is repaired.
311
312             sv4cpio  The System V release 4 cpio.  The default blocksize for
313                      this format is 5120 bytes.  Inode and device information
314                      about a file (used for detecting file hard links by this
315                      format) which may be truncated by this format is
316                      detected by pax and is repaired.
317
318             sv4crc   The System V release 4 cpio with file crc checksums.
319                      The default blocksize for this format is 5120 bytes.
320                      Inode and device information about a file (used for
321                      detecting file hard links by this format) which may be
322                      truncated by this format is detected by pax and is
323                      repaired.
324
325             tar      The old BSD tar format as found in BSD4.3.  The default
326                      blocksize for this format is 10240 bytes.  Pathnames
327                      stored by this format must be 100 characters or less in
328                      length (including the trailing   character, which means
329                      that filenames can have a maximum length of 99 charac‐
330                      ters).  Only regular files, hard links, soft links, and
331                      directories will be archived (other file system types
332                      are not supported).  For backwards compatibility with
333                      even older tar formats, a -o option can be used when
334                      writing an archive to omit the storage of directories.
335                      This option takes the form:
336                            -o write_opt=nodir
337
338             ustar    The extended tar interchange format specified in the
339                      IEEE Std 1003.2 (“POSIX.2”) standard.  The default
340                      blocksize for this format is 10240 bytes.  Filenames
341                      stored by this format must be 100 characters or less in
342                      length (including the trailing   character, which means
343                      that filenames can have a maximum length of 99 charac‐
344                      ters).  Pathnames (directorynames + filenames) stored by
345                      this format must be 250 characters or less in length.
346
347             pax will detect and report any file that it is unable to store or
348             extract as the result of any specific archive format restric‐
349             tions.  The individual archive formats may impose additional
350             restrictions on use.  Typical archive format restrictions include
351             (but are not limited to): file pathname length, file size, link
352             pathname length, and the type of the file.
353
354     -z      Use gzip(1) to compress (decompress) the archive while writing
355             (reading).  Incompatible with -a.
356
357     -B bytes
358             Limit the number of bytes written to a single archive volume to
359             bytes.  The bytes limit can end with ‘m’, ‘k’, or ‘b’ to specify
360             multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
361             A pair of bytes limits can be separated by ‘x’ to indicate a
362             product.
363
364             Warning: Only use this option when writing an archive to a device
365             which supports an end of file read condition based on last (or
366             largest) write offset (such as a regular file or a tape drive).
367             The use of this option with a floppy or hard disk is not recom‐
368             mended.
369
370     -D      This option is the same as the -u option, except that the file
371             inode change time is checked instead of the file modification
372             time.  The file inode change time can be used to select files
373             whose inode information (e.g., UID, GID, etc.) is newer than a
374             copy of the file in the destination directory.
375
376     -E limit
377             Limit the number of consecutive read faults while trying to read
378             a flawed archive to limit.  With a positive limit, pax will
379             attempt to recover from an archive read error and will continue
380             processing starting with the next file stored in the archive.  A
381             limit of 0 will cause pax to stop operation after the first read
382             error is detected on an archive volume.  A limit of NONE will
383             cause pax to attempt to recover from read errors forever.  The
384             default limit is a small positive number of retries.
385
386             Warning: Using this option with NONE should be used with extreme
387             caution as pax may get stuck in an infinite loop on a very badly
388             flawed archive.
389
390     -G group
391             Select a file based on its group name, or when starting with a #,
392             a numeric gid.  A ‘\’ can be used to escape the #.  Multiple -G
393             options may be supplied and checking stops with the first match.
394
395     -H      Follow only command-line symbolic links while performing a physi‐
396             cal file system traversal.
397
398     -L      Follow all symbolic links to perform a logical file system tra‐
399             versal.
400
401     -O      Force the archive to be one volume.  If a volume ends prema‐
402             turely, pax will not prompt for a new volume.  This option can be
403             useful for automated tasks where error recovery cannot be per‐
404             formed by a human.
405
406     -P      Do not follow symbolic links, perform a physical file system tra‐
407             versal.  This is the default mode.
408
409     -T [from_date][,to_date][/[c][m]]
410             Allow files to be selected based on a file modification or inode
411             change time falling within a specified time range of from_date to
412             to_date (the dates are inclusive).  If only a from_date is sup‐
413             plied, all files with a modification or inode change time equal
414             to or younger are selected.  If only a to_date is supplied, all
415             files with a modification or inode change time equal to or older
416             will be selected.  When the from_date is equal to the to_date,
417             only files with a modification or inode change time of exactly
418             that time will be selected.
419
420             When pax is in the write or copy mode, the optional trailing
421             field [c][m] can be used to determine which file time (inode
422             change, file modification or both) are used in the comparison.
423             If neither is specified, the default is to use file modification
424             time only.  The m specifies the comparison of file modification
425             time (the time when the file was last written).  The c specifies
426             the comparison of inode change time (the time when the file inode
427             was last changed; e.g., a change of owner, group, mode, etc).
428             When c and m are both specified, then the modification and inode
429             change times are both compared.  The inode change time comparison
430             is useful in selecting files whose attributes were recently
431             changed or selecting files which were recently created and had
432             their modification time reset to an older time (as what happens
433             when a file is extracted from an archive and the modification
434             time is preserved).  Time comparisons using both file times is
435             useful when pax is used to create a time based incremental ar‐
436             chive (only files that were changed during a specified time range
437             will be archived).
438
439             A time range is made up of six different fields and each field
440             must contain two digits.  The format is:
441                   [[[[[cc]yy]mm]dd]HH]MM[.SS]
442             Where cc is the first two digits of the year (the century), yy is
443             the last two digits of the year, the first mm is the month (from
444             01 to 12), dd is the day of the month (from 01 to 31), HH is the
445             hour of the day (from 00 to 23), MM is the minute (from 00 to
446             59), and SS is the seconds (from 00 to 59).  The minute field MM
447             is required, while the other fields are optional and must be
448             added in the following order:
449                  HH, dd, mm, yy, cc.
450             The SS field may be added independently of the other fields.
451             Time ranges are relative to the current time, so
452                   -T 1234/cm
453             would select all files with a modification or inode change time
454             of 12:34 PM today or later.  Multiple -T time range can be sup‐
455             plied and checking stops with the first match.
456
457     -U user
458             Select a file based on its user name, or when starting with a #,
459             a numeric UID.  A ‘\’ can be used to escape the #.  Multiple -U
460             options may be supplied and checking stops with the first match.
461
462     -X      When traversing the file hierarchy specified by a pathname, do
463             not descend into directories that have a different device ID.
464             See the st_dev field as described in stat(2) for more information
465             about device IDs.
466
467     -Y      This option is the same as the -D option, except that the inode
468             change time is checked using the pathname created after all the
469             file name modifications have completed.
470
471     -Z      This option is the same as the -u option, except that the modifi‐
472             cation time is checked using the pathname created after all the
473             file name modifications have completed.
474
475     The options that operate on the names of files or archive members (-c,
476     -i, -n, -s, -u, -v, -D, -G, -T, -U, -Y, and -Z) interact as follows.
477
478     When extracting files during a read operation, archive members are
479     ‘selected’, based only on the user specified pattern operands as modified
480     by the -c, -n, -u, -D, -G, -T, -U options.  Then any -s and -i options
481     will modify in that order, the names of these selected files.  Then the
482     -Y and -Z options will be applied based on the final pathname.  Finally,
483     the -v option will write the names resulting from these modifications.
484
485     When archiving files during a write operation, or copying files during a
486     copy operation, archive members are ‘selected’, based only on the user
487     specified pathnames as modified by the -n, -u, -D, -G, -T, and -U options
488     (the -D option only applies during a copy operation).  Then any -s and -i
489     options will modify in that order, the names of these selected files.
490     Then during a copy operation the -Y and the -Z options will be applied
491     based on the final pathname.  Finally, the -v option will write the names
492     resulting from these modifications.
493
494     When one or both of the -u or -D options are specified along with the -n
495     option, a file is not considered selected unless it is newer than the
496     file to which it is compared.
497

ENVIRONMENT

499     TMPDIR      Path in which to store temporary files.
500

EXAMPLES

502     $ pax -w -f /dev/rst0 .
503
504     Copies the contents of the current directory to the device /dev/rst0.
505
506     $ pax -v -f filename
507
508     Gives the verbose table of contents for an archive stored in filename.
509
510     $ mkdir newdir; cd olddir; pax -rw . newdir
511
512     This sequence of commands will copy the entire olddir directory hierarchy
513     to newdir.
514
515     $ pax -r -s ',^//*usr//*,,' -f a.pax
516
517     Reads the archive a.pax, with all files rooted in /usr into the archive
518     extracted relative to the current directory.
519
520     $ pax -rw -i . dest_dir
521
522     Can be used to interactively select the files to copy from the current
523     directory to dest_dir.
524
525     $ pax -r -pe -U root -G bin -f a.pax
526
527     Extract all files from the archive a.pax which are owned by root with
528     group bin and preserve all file permissions.
529
530     $ pax -r -w -v -Y -Z home /backup
531
532     Update (and list) only those files in the destination directory /backup
533     which are older (less recent inode change or file modification times)
534     than files with the same name found in the source file tree home.
535

DIAGNOSTICS

537     pax will exit with one of the following values:
538
539     0   All files were processed successfully.
540
541     1   An error occurred.
542
543     Whenever pax cannot create a file or a link when reading an archive or
544     cannot find a file when writing an archive, or cannot preserve the user
545     ID, group ID, or file mode when the -p option is specified, a diagnostic
546     message is written to standard error and a non-zero exit status will be
547     returned, but processing will continue.  In the case where pax cannot
548     create a link to a file, pax will not create a second copy of the file.
549
550     If the extraction of a file from an archive is prematurely terminated by
551     a signal or error, pax may have only partially extracted a file the user
552     wanted.  Additionally, the file modes of extracted files and directories
553     may have incorrect file bits, and the modification and access times may
554     be wrong.
555
556     If the creation of an archive is prematurely terminated by a signal or
557     error, pax may have only partially created the archive which may violate
558     the specific archive format specification.
559
560     If while doing a copy, pax detects a file is about to overwrite itself,
561     the file is not copied, a diagnostic message is written to standard error
562     and when pax completes it will exit with a non-zero exit status.
563

SEE ALSO

565     cpio(1), tar(1)
566

STANDARDS

568     The pax utility is a superset of the IEEE Std 1003.2 (“POSIX.2”) stan‐
569     dard.  The options -B, -D, -E, -G, -H, -L, -O, -P, -T, -U, -Y, -Z, the
570     archive formats bcpio, sv4cpio, sv4crc, tar, and the flawed archive han‐
571     dling during list and read operations are extensions to the POSIX stan‐
572     dard.
573

AUTHORS

575     Keith Muller at the University of California, San Diego.
576
577BSD                             April 18, 1994                             BSD
Impressum