]> git.saurik.com Git - apple/file_cmds.git/blob - pax/pax.1
8df49bd8f8dd73411e452a3c178863554c198944
[apple/file_cmds.git] / pax / pax.1
1 .\" Copyright (c) 1992 Keith Muller.
2 .\" Copyright (c) 1992, 1993
3 .\" The Regents of the University of California. All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Keith Muller of the University of California, San Diego.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" @(#)pax.1 8.4 (Berkeley) 4/18/94
33 .\" $FreeBSD: src/bin/pax/pax.1,v 1.33 2004/07/03 02:03:44 tjr Exp $
34 .\"
35 .Dd July 3, 2004
36 .Dt PAX 1
37 .Os
38 .Sh NAME
39 .Nm pax
40 .Nd read and write file archives and copy directory hierarchies
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl cdnvz
44 .Bk -words
45 .Op Fl f Ar archive
46 .Ek
47 .Bk -words
48 .Op Fl s Ar replstr
49 .Ar ...\&
50 .Ek
51 .Bk -words
52 .Op Fl U Ar user
53 .Ar ...\&
54 .Ek
55 .Bk -words
56 .Op Fl G Ar group
57 .Ar ...\&
58 .Ek
59 .Bk -words
60 .Oo
61 .Fl T
62 .Op Ar from_date
63 .Op Ar ,to_date
64 .Oc
65 .Ar ...\&
66 .Ek
67 .Op Ar pattern ...\&
68 .Nm
69 .Fl r
70 .Op Fl cdiknuvzDYZ
71 .Bk -words
72 .Op Fl f Ar archive
73 .Ek
74 .Bk -words
75 .Op Fl o Ar options
76 .Ar ...\&
77 .Ek
78 .Bk -words
79 .Op Fl p Ar string
80 .Ar ...\&
81 .Ek
82 .Bk -words
83 .Op Fl s Ar replstr
84 .Ar ...\&
85 .Ek
86 .Op Fl E Ar limit
87 .Bk -words
88 .Op Fl U Ar user
89 .Ar ...\&
90 .Ek
91 .Bk -words
92 .Op Fl G Ar group
93 .Ar ...\&
94 .Ek
95 .Bk -words
96 .Oo
97 .Fl T
98 .Op Ar from_date
99 .Op Ar ,to_date
100 .Oc
101 .Ar ...\&
102 .Ek
103 .Op Ar pattern ...\&
104 .Nm
105 .Fl w
106 .Op Fl dituvzHLPX
107 .Bk -words
108 .Op Fl b Ar blocksize
109 .Ek
110 .Oo
111 .Op Fl a
112 .Op Fl f Ar archive
113 .Oc
114 .Bk -words
115 .Op Fl x Ar format
116 .Ek
117 .Bk -words
118 .Op Fl s Ar replstr
119 .Ar ...\&
120 .Ek
121 .Bk -words
122 .Op Fl o Ar options
123 .Ar ...\&
124 .Ek
125 .Bk -words
126 .Op Fl U Ar user
127 .Ar ...\&
128 .Ek
129 .Bk -words
130 .Op Fl G Ar group
131 .Ar ...\&
132 .Ek
133 .Bk -words
134 .Op Fl B Ar bytes
135 .Ek
136 .Bk -words
137 .Oo
138 .Fl T
139 .Op Ar from_date
140 .Op Ar ,to_date
141 .Op Ar /[c][m]
142 .Oc
143 .Ar ...\&
144 .Ek
145 .Op Ar
146 .Nm
147 .Fl r
148 .Fl w
149 .Op Fl diklntuvDHLPXYZ
150 .Bk -words
151 .Op Fl p Ar string
152 .Ar ...\&
153 .Ek
154 .Bk -words
155 .Op Fl s Ar replstr
156 .Ar ...\&
157 .Ek
158 .Bk -words
159 .Op Fl U Ar user
160 .Ar ...\&
161 .Ek
162 .Bk -words
163 .Op Fl G Ar group
164 .Ar ...\&
165 .Ek
166 .Bk -words
167 .Oo
168 .Fl T
169 .Op Ar from_date
170 .Op Ar ,to_date
171 .Op Ar /[c][m]
172 .Oc
173 .Ar ...\&
174 .Ek
175 .Op Ar
176 .Ar directory
177 .Sh DESCRIPTION
178 The
179 .Nm
180 utility will read, write, and list the members of an archive file,
181 and will copy directory hierarchies.
182 These operations are independent of the specific archive format,
183 and support a wide variety of different archive formats.
184 A list of supported archive formats can be found under the description of the
185 .Fl x
186 option.
187 .Pp
188 The presence of the
189 .Fl r
190 and the
191 .Fl w
192 options specifies which of the following functional modes
193 .Nm
194 will operate under:
195 .Em list , read , write ,
196 and
197 .Em copy .
198 .Bl -tag -width 6n
199 .It <none>
200 .Em List .
201 Write to
202 .Dv standard output
203 a table of contents of the members of the archive file read from
204 .Dv standard input ,
205 whose pathnames match the specified
206 .Ar patterns .
207 The table of contents contains one filename per line
208 and is written using single line buffering.
209 .It Fl r
210 .Em Read .
211 Extract the members of the archive file read from the
212 .Dv standard input ,
213 with pathnames matching the specified
214 .Ar patterns .
215 The archive format and blocking is automatically determined on input.
216 When an extracted file is a directory, the entire file hierarchy
217 rooted at that directory is extracted.
218 All extracted files are created relative to the current file hierarchy.
219 The setting of ownership, access and modification times, and file mode of
220 the extracted files are discussed in more detail under the
221 .Fl p
222 option.
223 .It Fl w
224 .Em Write .
225 Write an archive containing the
226 .Ar file
227 operands to
228 .Dv standard output
229 using the specified archive format.
230 When no
231 .Ar file
232 operands are specified, a list of files to copy with one per line is read from
233 .Dv standard input .
234 When a
235 .Ar file
236 operand is also a directory, the entire file hierarchy rooted
237 at that directory will be included.
238 .It Fl r Fl w
239 .Em Copy .
240 Copy the
241 .Ar file
242 operands to the destination
243 .Ar directory .
244 When no
245 .Ar file
246 operands are specified, a list of files to copy with one per line is read from
247 the
248 .Dv standard input .
249 When a
250 .Ar file
251 operand is also a directory the entire file
252 hierarchy rooted at that directory will be included.
253 The effect of the
254 .Em copy
255 is as if the copied files were written to an archive file and then
256 subsequently extracted, except that there may be hard links between
257 the original and the copied files (see the
258 .Fl l
259 option below).
260 .Pp
261 .Em Warning :
262 The destination
263 .Ar directory
264 must not be one of the
265 .Ar file
266 operands or a member of a file hierarchy rooted at one of the
267 .Ar file
268 operands.
269 The result of a
270 .Em copy
271 under these conditions is unpredictable.
272 .El
273 .Pp
274 While processing a damaged archive during a
275 .Em read
276 or
277 .Em list
278 operation,
279 .Nm
280 will attempt to recover from media defects and will search through the archive
281 to locate and process the largest number of archive members possible (see the
282 .Fl E
283 option for more details on error handling).
284 .Sh OPERANDS
285 The
286 .Ar directory
287 operand specifies a destination directory pathname.
288 If the
289 .Ar directory
290 operand does not exist, or it is not writable by the user,
291 or it is not of type directory,
292 .Nm
293 will exit with a non-zero exit status.
294 .Pp
295 The
296 .Ar pattern
297 operand is used to select one or more pathnames of archive members.
298 Archive members are selected using the pattern matching notation described
299 by
300 .Xr fnmatch 3 .
301 When the
302 .Ar pattern
303 operand is not supplied, all members of the archive will be selected.
304 When a
305 .Ar pattern
306 matches a directory, the entire file hierarchy rooted at that directory will
307 be selected.
308 When a
309 .Ar pattern
310 operand does not select at least one archive member,
311 .Nm
312 will write these
313 .Ar pattern
314 operands in a diagnostic message to
315 .Dv standard error
316 and then exit with a non-zero exit status.
317 .Pp
318 The
319 .Ar file
320 operand specifies the pathname of a file to be copied or archived.
321 When a
322 .Ar file
323 operand does not select at least one archive member,
324 .Nm
325 will write these
326 .Ar file
327 operand pathnames in a diagnostic message to
328 .Dv standard error
329 and then exit with a non-zero exit status.
330 .Sh OPTIONS
331 The following options are supported:
332 .Bl -tag -width 4n
333 .It Fl r
334 Read an archive file from
335 .Dv standard input
336 and extract the specified
337 .Ar files .
338 If any intermediate directories are needed in order to extract an archive
339 member, these directories will be created as if
340 .Xr mkdir 2
341 was called with the bitwise inclusive
342 .Dv OR
343 of
344 .Dv S_IRWXU , S_IRWXG ,
345 and
346 .Dv S_IRWXO
347 as the mode argument.
348 When the selected archive format supports the specification of linked
349 files and these files cannot be linked while the archive is being extracted,
350 .Nm
351 will write a diagnostic message to
352 .Dv standard error
353 and exit with a non-zero exit status at the completion of operation.
354 .It Fl w
355 Write files to the
356 .Dv standard output
357 in the specified archive format.
358 When no
359 .Ar file
360 operands are specified,
361 .Dv standard input
362 is read for a list of pathnames with one per line without any leading or
363 trailing
364 .Aq blanks .
365 .It Fl a
366 Append
367 .Ar files
368 to the end of an archive that was previously written.
369 If an archive format is not specified with a
370 .Fl x
371 option, the format currently being used in the archive will be selected.
372 Any attempt to append to an archive in a format different from the
373 format already used in the archive will cause
374 .Nm
375 to exit immediately
376 with a non-zero exit status.
377 The blocking size used in the archive volume where writing starts
378 will continue to be used for the remainder of that archive volume.
379 .Pp
380 .Em Warning :
381 Many storage devices are not able to support the operations necessary
382 to perform an append operation.
383 Any attempt to append to an archive stored on such a device may damage the
384 archive or have other unpredictable results.
385 Tape drives in particular are more likely to not support an append operation.
386 An archive stored in a regular file system file or on a disk device will
387 usually support an append operation.
388 .It Fl b Ar blocksize
389 When
390 .Em writing
391 an archive,
392 block the output at a positive decimal integer number of
393 bytes per write to the archive file.
394 The
395 .Ar blocksize
396 must be a multiple of 512 bytes with a maximum of 64512 bytes.
397 Archives larger than 32256 bytes violate the
398 .Tn POSIX
399 standard and will not be portable to all systems.
400 A
401 .Ar blocksize
402 can end with
403 .Li k
404 or
405 .Li b
406 to specify multiplication by 1024 (1K) or 512, respectively.
407 A pair of
408 .Ar blocksizes
409 can be separated by
410 .Li x
411 to indicate a product.
412 A specific archive device may impose additional restrictions on the size
413 of blocking it will support.
414 When blocking is not specified, the default
415 .Ar blocksize
416 is dependent on the specific archive format being used (see the
417 .Fl x
418 option).
419 .It Fl c
420 Match all file or archive members
421 .Em except
422 those specified by the
423 .Ar pattern
424 and
425 .Ar file
426 operands.
427 .It Fl d
428 Cause files of type directory being copied or archived, or archive members of
429 type directory being extracted, to match only the directory file or archive
430 member and not the file hierarchy rooted at the directory.
431 .It Fl f Ar archive
432 Specify
433 .Ar archive
434 as the pathname of the input or output archive, overriding the default
435 .Dv standard input
436 (for
437 .Em list
438 and
439 .Em read )
440 or
441 .Dv standard output
442 (for
443 .Em write ) .
444 A single archive may span multiple files and different archive devices.
445 When required,
446 .Nm
447 will prompt for the pathname of the file or device of the next volume in the
448 archive.
449 .It Fl i
450 Interactively rename files or archive members.
451 For each archive member matching a
452 .Ar pattern
453 operand or each file matching a
454 .Ar file
455 operand,
456 .Nm
457 will prompt to
458 .Pa /dev/tty
459 giving the name of the file, its file mode and its modification time.
460 The
461 .Nm
462 utility will then read a line from
463 .Pa /dev/tty .
464 If this line is blank, the file or archive member is skipped.
465 If this line consists of a single period, the
466 file or archive member is processed with no modification to its name.
467 Otherwise, its name is replaced with the contents of the line.
468 The
469 .Nm
470 utility will immediately exit with a non-zero exit status if
471 .Dv <EOF>
472 is encountered when reading a response or if
473 .Pa /dev/tty
474 cannot be opened for reading and writing.
475 .It Fl k
476 Do not overwrite existing files.
477 .It Fl l
478 Link files.
479 (The letter ell).
480 In the
481 .Em copy
482 mode
483 .Pq Fl r w ,
484 hard links are made between the source and destination file hierarchies
485 whenever possible.
486 .It Fl n
487 Select the first archive member that matches each
488 .Ar pattern
489 operand.
490 No more than one archive member is matched for each
491 .Ar pattern .
492 When members of type directory are matched, the file hierarchy rooted at that
493 directory is also matched (unless
494 .Fl d
495 is also specified).
496 .It Fl o Ar options
497 Information to modify the algorithm for extracting or writing archive files
498 which is specific to the archive format specified by
499 .Fl x .
500 In general,
501 .Ar options
502 take the form:
503 .Cm name=value
504 .It Fl p Ar string
505 Specify one or more file characteristic options (privileges).
506 The
507 .Ar string
508 option-argument is a string specifying file characteristics to be retained or
509 discarded on extraction.
510 The string consists of the specification characters
511 .Cm a , e , m , o ,
512 and
513 .Cm p .
514 Multiple characteristics can be concatenated within the same string
515 and multiple
516 .Fl p
517 options can be specified.
518 The meaning of the specification characters are as follows:
519 .Bl -tag -width 2n
520 .It Cm a
521 Do not preserve file access times.
522 By default, file access times are preserved whenever possible.
523 .It Cm e
524 .Sq Preserve everything ,
525 the user ID, group ID, file mode bits,
526 file access time, and file modification time.
527 This is intended to be used by
528 .Em root ,
529 someone with all the appropriate privileges, in order to preserve all
530 aspects of the files as they are recorded in the archive.
531 The
532 .Cm e
533 flag is the sum of the
534 .Cm o
535 and
536 .Cm p
537 flags.
538 .It Cm m
539 Do not preserve file modification times.
540 By default, file modification times are preserved whenever possible.
541 .It Cm o
542 Preserve the user ID and group ID.
543 .It Cm p
544 .Sq Preserve
545 the file mode bits.
546 This intended to be used by a
547 .Em user
548 with regular privileges who wants to preserve all aspects of the file other
549 than the ownership.
550 The file times are preserved by default, but two other flags are offered to
551 disable this and use the time of extraction instead.
552 .El
553 .Pp
554 In the preceding list,
555 .Sq preserve
556 indicates that an attribute stored in the archive is given to the
557 extracted file, subject to the permissions of the invoking
558 process.
559 Otherwise the attribute of the extracted file is determined as
560 part of the normal file creation action.
561 If neither the
562 .Cm e
563 nor the
564 .Cm o
565 specification character is specified, or the user ID and group ID are not
566 preserved for any reason,
567 .Nm
568 will not set the
569 .Dv S_ISUID
570 .Em ( setuid )
571 and
572 .Dv S_ISGID
573 .Em ( setgid )
574 bits of the file mode.
575 If the preservation of any of these items fails for any reason,
576 .Nm
577 will write a diagnostic message to
578 .Dv standard error .
579 Failure to preserve these items will affect the final exit status,
580 but will not cause the extracted file to be deleted.
581 If the file characteristic letters in any of the string option-arguments are
582 duplicated or conflict with each other, the one(s) given last will take
583 precedence.
584 For example, if
585 .Dl Fl p Ar eme
586 is specified, file modification times are still preserved.
587 .It Fl s Ar replstr
588 Modify the file or archive member names specified by the
589 .Ar pattern
590 or
591 .Ar file
592 operands according to the substitution expression
593 .Ar replstr ,
594 using the syntax of the
595 .Xr ed 1
596 utility regular expressions.
597 The format of these regular expressions are:
598 .Dl /old/new/[gp]
599 As in
600 .Xr ed 1 ,
601 .Cm old
602 is a basic regular expression and
603 .Cm new
604 can contain an ampersand (&), \\n (where n is a digit) back-references,
605 or subexpression matching.
606 The
607 .Cm old
608 string may also contain
609 .Dv <newline>
610 characters.
611 Any non-null character can be used as a delimiter (/ is shown here).
612 Multiple
613 .Fl s
614 expressions can be specified.
615 The expressions are applied in the order they are specified on the
616 command line, terminating with the first successful substitution.
617 The optional trailing
618 .Cm g
619 continues to apply the substitution expression to the pathname substring
620 which starts with the first character following the end of the last successful
621 substitution.
622 The first unsuccessful substitution stops the operation of the
623 .Cm g
624 option.
625 The optional trailing
626 .Cm p
627 will cause the final result of a successful substitution to be written to
628 .Dv standard error
629 in the following format:
630 .Dl <original pathname> >> <new pathname>
631 File or archive member names that substitute to the empty string
632 are not selected and will be skipped.
633 .It Fl t
634 Reset the access times of any file or directory read or accessed by
635 .Nm
636 to be the same as they were before being read or accessed by
637 .Nm .
638 .It Fl u
639 Ignore files that are older (having a less recent file modification time)
640 than a pre-existing file or archive member with the same name.
641 During
642 .Em read ,
643 an archive member with the same name as a file in the file system will be
644 extracted if the archive member is newer than the file.
645 During
646 .Em write ,
647 a file system member with the same name as an archive member will be
648 written to the archive if it is newer than the archive member.
649 During
650 .Em copy ,
651 the file in the destination hierarchy is replaced by the file in the source
652 hierarchy or by a link to the file in the source hierarchy if the file in
653 the source hierarchy is newer.
654 .It Fl v
655 During a
656 .Em list
657 operation, produce a verbose table of contents using the format of the
658 .Xr ls 1
659 utility with the
660 .Fl l
661 option.
662 For pathnames representing a hard link to a previous member of the archive,
663 the output has the format:
664 .Dl <ls -l listing> == <link name>
665 For pathnames representing a symbolic link, the output has the format:
666 .Dl <ls -l listing> => <link name>
667 Where <ls -l listing> is the output format specified by the
668 .Xr ls 1
669 utility when used with the
670 .Fl l
671 option.
672 Otherwise for all the other operational modes
673 .Em ( read , write ,
674 and
675 .Em copy ) ,
676 pathnames are written and flushed to
677 .Dv standard error
678 without a trailing
679 .Dv <newline>
680 as soon as processing begins on that file or
681 archive member.
682 The trailing
683 .Dv <newline> ,
684 is not buffered, and is written only after the file has been read or written.
685 .It Fl x Ar format
686 Specify the output archive format, with the default format being
687 .Ar ustar .
688 The
689 .Nm
690 utility currently supports the following formats:
691 .Bl -tag -width "sv4cpio"
692 .It Ar cpio
693 The extended cpio interchange format specified in the
694 .St -p1003.2
695 standard.
696 The default blocksize for this format is 5120 bytes.
697 Inode and device information about a file (used for detecting file hard links
698 by this format) which may be truncated by this format is detected by
699 .Nm
700 and is repaired.
701 .It Ar bcpio
702 The old binary cpio format.
703 The default blocksize for this format is 5120 bytes.
704 This format is not very portable and should not be used when other formats
705 are available.
706 Inode and device information about a file (used for detecting file hard links
707 by this format) which may be truncated by this format is detected by
708 .Nm
709 and is repaired.
710 .It Ar sv4cpio
711 The System V release 4 cpio.
712 The default blocksize for this format is 5120 bytes.
713 Inode and device information about a file (used for detecting file hard links
714 by this format) which may be truncated by this format is detected by
715 .Nm
716 and is repaired.
717 .It Ar sv4crc
718 The System V release 4 cpio with file crc checksums.
719 The default blocksize for this format is 5120 bytes.
720 Inode and device information about a file (used for detecting file hard links
721 by this format) which may be truncated by this format is detected by
722 .Nm
723 and is repaired.
724 .It Ar tar
725 The old
726 .Bx
727 tar format as found in
728 .Bx 4.3 .
729 The default blocksize for this format is 10240 bytes.
730 Pathnames stored by this format must be 100 characters or less in length.
731 Only
732 .Em regular
733 files,
734 .Em hard links , soft links ,
735 and
736 .Em directories
737 will be archived (other file system types are not supported).
738 For backwards compatibility with even older tar formats, a
739 .Fl o
740 option can be used when writing an archive to omit the storage of directories.
741 This option takes the form:
742 .Dl Fl o Cm write_opt=nodir
743 .It Ar ustar
744 The extended tar interchange format specified in the
745 .St -p1003.2
746 standard.
747 The default blocksize for this format is 10240 bytes.
748 Pathnames stored by this format must be 250 characters or less in length.
749 .El
750 .Pp
751 The
752 .Nm
753 utility will detect and report any file that it is unable to store or extract
754 as the result of any specific archive format restrictions.
755 The individual archive formats may impose additional restrictions on use.
756 Typical archive format restrictions include (but are not limited to):
757 file pathname length, file size, link pathname length and the type of the file.
758 .It Fl z
759 Use
760 .Xr gzip 1
761 to compress (decompress) the archive while writing (reading).
762 Incompatible with
763 .Fl a .
764 .It Fl B Ar bytes
765 Limit the number of bytes written to a single archive volume to
766 .Ar bytes .
767 The
768 .Ar bytes
769 limit can end with
770 .Li m ,
771 .Li k ,
772 or
773 .Li b
774 to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
775 A pair of
776 .Ar bytes
777 limits can be separated by
778 .Li x
779 to indicate a product.
780 .Pp
781 .Em Warning :
782 Only use this option when writing an archive to a device which supports
783 an end of file read condition based on last (or largest) write offset
784 (such as a regular file or a tape drive).
785 The use of this option with a floppy or hard disk is not recommended.
786 .It Fl D
787 This option is the same as the
788 .Fl u
789 option, except that the file inode change time is checked instead of the
790 file modification time.
791 The file inode change time can be used to select files whose inode information
792 (e.g.\& uid, gid, etc.) is newer than a copy of the file in the destination
793 .Ar directory .
794 .It Fl E Ar limit
795 Limit the number of consecutive read faults while trying to read a flawed
796 archives to
797 .Ar limit .
798 With a positive
799 .Ar limit ,
800 .Nm
801 will attempt to recover from an archive read error and will
802 continue processing starting with the next file stored in the archive.
803 A
804 .Ar limit
805 of 0 will cause
806 .Nm
807 to stop operation after the first read error is detected on an archive volume.
808 A
809 .Ar limit
810 of
811 .Li NONE
812 will cause
813 .Nm
814 to attempt to recover from read errors forever.
815 The default
816 .Ar limit
817 is a small positive number of retries.
818 .Pp
819 .Em Warning :
820 Using this option with
821 .Li NONE
822 should be used with extreme caution as
823 .Nm
824 may get stuck in an infinite loop on a very badly flawed archive.
825 .It Fl G Ar group
826 Select a file based on its
827 .Ar group
828 name, or when starting with a
829 .Cm # ,
830 a numeric gid.
831 A '\\' can be used to escape the
832 .Cm # .
833 Multiple
834 .Fl G
835 options may be supplied and checking stops with the first match.
836 .It Fl H
837 Follow only command line symbolic links while performing a physical file
838 system traversal.
839 .It Fl L
840 Follow all symbolic links to perform a logical file system traversal.
841 .It Fl P
842 Do not follow symbolic links, perform a physical file system traversal.
843 This is the default mode.
844 .It Fl T Ar [from_date][,to_date][/[c][m]]
845 Allow files to be selected based on a file modification or inode change
846 time falling within a specified time range of
847 .Ar from_date
848 to
849 .Ar to_date
850 (the dates are inclusive).
851 If only a
852 .Ar from_date
853 is supplied, all files with a modification or inode change time
854 equal to or younger are selected.
855 If only a
856 .Ar to_date
857 is supplied, all files with a modification or inode change time
858 equal to or older will be selected.
859 When the
860 .Ar from_date
861 is equal to the
862 .Ar to_date ,
863 only files with a modification or inode change time of exactly that
864 time will be selected.
865 .Pp
866 When
867 .Nm
868 is in the
869 .Em write
870 or
871 .Em copy
872 mode, the optional trailing field
873 .Ar [c][m]
874 can be used to determine which file time (inode change, file modification or
875 both) are used in the comparison.
876 If neither is specified, the default is to use file modification time only.
877 The
878 .Ar m
879 specifies the comparison of file modification time (the time when
880 the file was last written).
881 The
882 .Ar c
883 specifies the comparison of inode change time (the time when the file
884 inode was last changed; e.g.\& a change of owner, group, mode, etc).
885 When
886 .Ar c
887 and
888 .Ar m
889 are both specified, then the modification and inode change times are
890 both compared.
891 The inode change time comparison is useful in selecting files whose
892 attributes were recently changed or selecting files which were recently
893 created and had their modification time reset to an older time (as what
894 happens when a file is extracted from an archive and the modification time
895 is preserved).
896 Time comparisons using both file times is useful when
897 .Nm
898 is used to create a time based incremental archive (only files that were
899 changed during a specified time range will be archived).
900 .Pp
901 A time range is made up of six different fields and each field must contain two
902 digits.
903 The format is:
904 .Dl [yy[mm[dd[hh]]]]mm[.ss]
905 Where
906 .Cm yy
907 is the last two digits of the year,
908 the first
909 .Cm mm
910 is the month (from 01 to 12),
911 .Cm dd
912 is the day of the month (from 01 to 31),
913 .Cm hh
914 is the hour of the day (from 00 to 23),
915 the second
916 .Cm mm
917 is the minute (from 00 to 59),
918 and
919 .Cm ss
920 is the seconds (from 00 to 59).
921 The minute field
922 .Cm mm
923 is required, while the other fields are optional and must be added in the
924 following order:
925 .Dl Cm hh , dd , mm , yy .
926 The
927 .Cm ss
928 field may be added independently of the other fields.
929 Time ranges are relative to the current time, so
930 .Dl Fl T Ar 1234/cm
931 would select all files with a modification or inode change time
932 of 12:34 PM today or later.
933 Multiple
934 .Fl T
935 time range can be supplied and checking stops with the first match.
936 .It Fl U Ar user
937 Select a file based on its
938 .Ar user
939 name, or when starting with a
940 .Cm # ,
941 a numeric uid.
942 A '\\' can be used to escape the
943 .Cm # .
944 Multiple
945 .Fl U
946 options may be supplied and checking stops with the first match.
947 .It Fl X
948 When traversing the file hierarchy specified by a pathname,
949 do not descend into directories that have a different device ID.
950 See the
951 .Li st_dev
952 field as described in
953 .Xr stat 2
954 for more information about device ID's.
955 .It Fl Y
956 This option is the same as the
957 .Fl D
958 option, except that the inode change time is checked using the
959 pathname created after all the file name modifications have completed.
960 .It Fl Z
961 This option is the same as the
962 .Fl u
963 option, except that the modification time is checked using the
964 pathname created after all the file name modifications have completed.
965 .El
966 .Pp
967 The options that operate on the names of files or archive members
968 .Fl ( c ,
969 .Fl i ,
970 .Fl n ,
971 .Fl s ,
972 .Fl u ,
973 .Fl v ,
974 .Fl D ,
975 .Fl G ,
976 .Fl T ,
977 .Fl U ,
978 .Fl Y ,
979 and
980 .Fl Z )
981 interact as follows.
982 .Pp
983 When extracting files during a
984 .Em read
985 operation, archive members are
986 .Sq selected ,
987 based only on the user specified pattern operands as modified by the
988 .Fl c ,
989 .Fl n ,
990 .Fl u ,
991 .Fl D ,
992 .Fl G ,
993 .Fl T ,
994 .Fl U
995 options.
996 Then any
997 .Fl s
998 and
999 .Fl i
1000 options will modify in that order, the names of these selected files.
1001 Then the
1002 .Fl Y
1003 and
1004 .Fl Z
1005 options will be applied based on the final pathname.
1006 Finally the
1007 .Fl v
1008 option will write the names resulting from these modifications.
1009 .Pp
1010 When archiving files during a
1011 .Em write
1012 operation, or copying files during a
1013 .Em copy
1014 operation, archive members are
1015 .Sq selected ,
1016 based only on the user specified pathnames as modified by the
1017 .Fl n ,
1018 .Fl u ,
1019 .Fl D ,
1020 .Fl G ,
1021 .Fl T ,
1022 and
1023 .Fl U
1024 options (the
1025 .Fl D
1026 option only applies during a copy operation).
1027 Then any
1028 .Fl s
1029 and
1030 .Fl i
1031 options will modify in that order, the names of these selected files.
1032 Then during a
1033 .Em copy
1034 operation the
1035 .Fl Y
1036 and the
1037 .Fl Z
1038 options will be applied based on the final pathname.
1039 Finally the
1040 .Fl v
1041 option will write the names resulting from these modifications.
1042 .Pp
1043 When one or both of the
1044 .Fl u
1045 or
1046 .Fl D
1047 options are specified along with the
1048 .Fl n
1049 option, a file is not considered selected unless it is newer
1050 than the file to which it is compared.
1051 .Sh EXAMPLES
1052 The command:
1053 .Dl "pax -w -f /dev/sa0 ."
1054 copies the contents of the current directory to the device
1055 .Pa /dev/sa0 .
1056 .Pp
1057 The command:
1058 .Dl pax -v -f filename
1059 gives the verbose table of contents for an archive stored in
1060 .Pa filename .
1061 .Pp
1062 The following commands:
1063 .Dl mkdir /tmp/to
1064 .Dl cd /tmp/from
1065 .Dl pax -rw .\ /tmp/to
1066 will copy the entire
1067 .Pa /tmp/from
1068 directory hierarchy to
1069 .Pa /tmp/to .
1070 .Pp
1071 The command:
1072 .Dl pax -r -s ',^//*usr//*,,' -f a.pax
1073 reads the archive
1074 .Pa a.pax ,
1075 with all files rooted in ``/usr'' into the archive extracted relative to the
1076 current directory.
1077 .Pp
1078 The command:
1079 .Dl pax -rw -i .\ dest_dir
1080 can be used to interactively select the files to copy from the current
1081 directory to
1082 .Pa dest_dir .
1083 .Pp
1084 The command:
1085 .Dl pax -r -pe -U root -G bin -f a.pax
1086 will extract all files from the archive
1087 .Pa a.pax
1088 which are owned by
1089 .Em root
1090 with group
1091 .Em bin
1092 and will preserve all file permissions.
1093 .Pp
1094 The command:
1095 .Dl pax -r -w -v -Y -Z home /backup
1096 will update (and list) only those files in the destination directory
1097 .Pa /backup
1098 which are older (less recent inode change or file modification times) than
1099 files with the same name found in the source file tree
1100 .Pa home .
1101 .Sh STANDARDS
1102 The
1103 .Nm
1104 utility is a superset of the
1105 .St -p1003.2
1106 standard.
1107 The options
1108 .Fl z ,
1109 .Fl B ,
1110 .Fl D ,
1111 .Fl E ,
1112 .Fl G ,
1113 .Fl H ,
1114 .Fl L ,
1115 .Fl P ,
1116 .Fl T ,
1117 .Fl U ,
1118 .Fl Y ,
1119 .Fl Z ,
1120 the archive formats
1121 .Ar bcpio ,
1122 .Ar sv4cpio ,
1123 .Ar sv4crc ,
1124 .Ar tar ,
1125 and the flawed archive handling during
1126 .Ar list
1127 and
1128 .Ar read
1129 operations are extensions to the
1130 .Tn POSIX
1131 standard.
1132 .Sh SEE ALSO
1133 .Xr cpio 1 ,
1134 .Xr tar 1
1135 .Sh HISTORY
1136 The
1137 .Nm
1138 utility appeared in
1139 .Bx 4.4 .
1140 .Sh AUTHORS
1141 .An Keith Muller
1142 at the University of California, San Diego
1143 .Sh DIAGNOSTICS
1144 The
1145 .Nm
1146 utility will exit with one of the following values:
1147 .Bl -tag -width 2n
1148 .It 0
1149 All files were processed successfully.
1150 .It 1
1151 An error occurred.
1152 .El
1153 .Pp
1154 Whenever
1155 .Nm
1156 cannot create a file or a link when reading an archive or cannot
1157 find a file when writing an archive, or cannot preserve the user ID,
1158 group ID, or file mode when the
1159 .Fl p
1160 option is specified, a diagnostic message is written to
1161 .Dv standard error
1162 and a non-zero exit status will be returned, but processing will continue.
1163 In the case where pax cannot create a link to a file,
1164 .Nm
1165 will not create a second copy of the file.
1166 .Pp
1167 If the extraction of a file from an archive is prematurely terminated by
1168 a signal or error,
1169 .Nm
1170 may have only partially extracted a file the user wanted.
1171 Additionally, the file modes of extracted files and directories
1172 may have incorrect file bits, and the modification and access times may be
1173 wrong.
1174 .Pp
1175 If the creation of an archive is prematurely terminated by a signal or error,
1176 .Nm
1177 may have only partially created the archive which may violate the specific
1178 archive format specification.
1179 .Pp
1180 If while doing a
1181 .Em copy ,
1182 .Nm
1183 detects a file is about to overwrite itself, the file is not copied,
1184 a diagnostic message is written to
1185 .Dv standard error
1186 and when
1187 .Nm
1188 completes it will exit with a non-zero exit status.
1189 .Sh BUGS
1190 The
1191 .Nm
1192 utility does not recognize multibyte characters.