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