Merge branch 'vendor/NCURSES'
[dragonfly.git] / bin / 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 .\" 3. 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.12.2.10 2003/02/23 17:46:34 keramida Exp $
34 .\"
35 .Dd March 27, 2009
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 cdnvzO
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 cdiknuvzDOYZ
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 dituvzHLOPX
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 diklntuvDHLOPXYZ
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 O
842 Force the archive to be one volume.  If a volume ends prematurely,
843 .Nm
844 will not prompt for a new volume.  This option can be useful for
845 automated tasks where error recovery cannot be performed by a human.
846 .It Fl P
847 Do not follow symbolic links, perform a physical file system traversal.
848 This is the default mode.
849 .It Fl T Ar [from_date][,to_date][/[c][m]]
850 Allow files to be selected based on a file modification or inode change
851 time falling within a specified time range of
852 .Ar from_date
853 to
854 .Ar to_date
855 (the dates are inclusive).
856 If only a
857 .Ar from_date
858 is supplied, all files with a modification or inode change time
859 equal to or younger are selected.
860 If only a
861 .Ar to_date
862 is supplied, all files with a modification or inode change time
863 equal to or older will be selected.
864 When the
865 .Ar from_date
866 is equal to the
867 .Ar to_date ,
868 only files with a modification or inode change time of exactly that
869 time will be selected.
870 .Pp
871 When
872 .Nm
873 is in the
874 .Em write
875 or
876 .Em copy
877 mode, the optional trailing field
878 .Ar [c][m]
879 can be used to determine which file time (inode change, file modification or
880 both) are used in the comparison.
881 If neither is specified, the default is to use file modification time only.
882 The
883 .Ar m
884 specifies the comparison of file modification time (the time when
885 the file was last written).
886 The
887 .Ar c
888 specifies the comparison of inode change time (the time when the file
889 inode was last changed; e.g. a change of owner, group, mode, etc).
890 When
891 .Ar c
892 and
893 .Ar m
894 are both specified, then the modification and inode change times are
895 both compared.
896 The inode change time comparison is useful in selecting files whose
897 attributes were recently changed or selecting files which were recently
898 created and had their modification time reset to an older time (as what
899 happens when a file is extracted from an archive and the modification time
900 is preserved).
901 Time comparisons using both file times is useful when
902 .Nm
903 is used to create a time based incremental archive (only files that were
904 changed during a specified time range will be archived).
905 .Pp
906 A time range is made up of six different fields and each field must contain two
907 digits.
908 The format is:
909 .Dl [yy[mm[dd[hh]]]]mm[.ss]
910 Where
911 .Cm yy
912 is the last two digits of the year,
913 the first
914 .Cm mm
915 is the month (from 01 to 12),
916 .Cm dd
917 is the day of the month (from 01 to 31),
918 .Cm hh
919 is the hour of the day (from 00 to 23),
920 the second
921 .Cm mm
922 is the minute (from 00 to 59),
923 and
924 .Cm ss
925 is the seconds (from 00 to 59).
926 The minute field
927 .Cm mm
928 is required, while the other fields are optional and must be added in the
929 following order:
930 .Dl Cm hh , dd , mm , yy .
931 The
932 .Cm ss
933 field may be added independently of the other fields.
934 Time ranges are relative to the current time, so
935 .Dl Fl T Ar 1234/cm
936 would select all files with a modification or inode change time
937 of 12:34 PM today or later.
938 Multiple
939 .Fl T
940 time range can be supplied and checking stops with the first match.
941 .It Fl U Ar user
942 Select a file based on its
943 .Ar user
944 name, or when starting with a
945 .Cm # ,
946 a numeric uid.
947 A '\\' can be used to escape the
948 .Cm # .
949 Multiple
950 .Fl U
951 options may be supplied and checking stops with the first match.
952 .It Fl X
953 When traversing the file hierarchy specified by a pathname,
954 do not descend into directories that have a different device ID.
955 See the
956 .Li st_dev
957 field as described in
958 .Xr stat 2
959 for more information about device ID's.
960 .It Fl Y
961 This option is the same as the
962 .Fl D
963 option, except that the inode change time is checked using the
964 pathname created after all the file name modifications have completed.
965 .It Fl Z
966 This option is the same as the
967 .Fl u
968 option, except that the modification time is checked using the
969 pathname created after all the file name modifications have completed.
970 .El
971 .Pp
972 The options that operate on the names of files or archive members
973 .Fl ( c ,
974 .Fl i ,
975 .Fl n ,
976 .Fl s ,
977 .Fl u ,
978 .Fl v ,
979 .Fl D ,
980 .Fl G ,
981 .Fl T ,
982 .Fl U ,
983 .Fl Y ,
984 and
985 .Fl Z )
986 interact as follows.
987 .Pp
988 When extracting files during a
989 .Em read
990 operation, archive members are
991 .Sq selected ,
992 based only on the user specified pattern operands as modified by the
993 .Fl c ,
994 .Fl n ,
995 .Fl u ,
996 .Fl D ,
997 .Fl G ,
998 .Fl T ,
999 .Fl U
1000 options.
1001 Then any
1002 .Fl s
1003 and
1004 .Fl i
1005 options will modify in that order, the names of these selected files.
1006 Then the
1007 .Fl Y
1008 and
1009 .Fl Z
1010 options will be applied based on the final pathname.
1011 Finally the
1012 .Fl v
1013 option will write the names resulting from these modifications.
1014 .Pp
1015 When archiving files during a
1016 .Em write
1017 operation, or copying files during a
1018 .Em copy
1019 operation, archive members are
1020 .Sq selected ,
1021 based only on the user specified pathnames as modified by the
1022 .Fl n ,
1023 .Fl u ,
1024 .Fl D ,
1025 .Fl G ,
1026 .Fl T ,
1027 and
1028 .Fl U
1029 options (the
1030 .Fl D
1031 option only applies during a copy operation).
1032 Then any
1033 .Fl s
1034 and
1035 .Fl i
1036 options will modify in that order, the names of these selected files.
1037 Then during a
1038 .Em copy
1039 operation the
1040 .Fl Y
1041 and the
1042 .Fl Z
1043 options will be applied based on the final pathname.
1044 Finally the
1045 .Fl v
1046 option will write the names resulting from these modifications.
1047 .Pp
1048 When one or both of the
1049 .Fl u
1050 or
1051 .Fl D
1052 options are specified along with the
1053 .Fl n
1054 option, a file is not considered selected unless it is newer
1055 than the file to which it is compared.
1056 .Sh EXAMPLES
1057 The command:
1058 .Dl "pax -w -f /dev/rst0 ."
1059 copies the contents of the current directory to the device
1060 .Pa /dev/rst0 .
1061 .Pp
1062 The command:
1063 .Dl pax -v -f filename
1064 gives the verbose table of contents for an archive stored in
1065 .Pa filename .
1066 .Pp
1067 The following commands:
1068 .Dl mkdir /tmp/to
1069 .Dl cd /tmp/from
1070 .Dl pax -rw .\ /tmp/to
1071 will copy the entire
1072 .Pa /tmp/from
1073 directory hierarchy to
1074 .Pa /tmp/to .
1075 .Pp
1076 The command:
1077 .Dl pax -r -s ',^//*usr//*,,' -f a.pax
1078 reads the archive
1079 .Pa a.pax ,
1080 with all files rooted in ``/usr'' into the archive extracted relative to the
1081 current directory.
1082 .Pp
1083 The command:
1084 .Dl pax -rw -i .\ dest_dir
1085 can be used to interactively select the files to copy from the current
1086 directory to
1087 .Pa dest_dir .
1088 .Pp
1089 The command:
1090 .Dl pax -r -pe -U root -G bin -f a.pax
1091 will extract all files from the archive
1092 .Pa a.pax
1093 which are owned by
1094 .Em root
1095 with group
1096 .Em bin
1097 and will preserve all file permissions.
1098 .Pp
1099 The command:
1100 .Dl pax -r -w -v -Y -Z home /backup
1101 will update (and list) only those files in the destination directory
1102 .Pa /backup
1103 which are older (less recent inode change or file modification times) than
1104 files with the same name found in the source file tree
1105 .Pa home .
1106 .Sh DIAGNOSTICS
1107 The
1108 .Nm
1109 utility will exit with one of the following values:
1110 .Bl -tag -width 2n
1111 .It 0
1112 All files were processed successfully.
1113 .It 1
1114 An error occurred.
1115 .El
1116 .Pp
1117 Whenever
1118 .Nm
1119 cannot create a file or a link when reading an archive or cannot
1120 find a file when writing an archive, or cannot preserve the user ID,
1121 group ID, or file mode when the
1122 .Fl p
1123 option is specified, a diagnostic message is written to
1124 .Dv standard error
1125 and a non-zero exit status will be returned, but processing will continue.
1126 In the case where
1127 .Nm
1128 cannot create a link to a file,
1129 .Nm
1130 will not create a second copy of the file.
1131 .Pp
1132 If the extraction of a file from an archive is prematurely terminated by
1133 a signal or error,
1134 .Nm
1135 may have only partially extracted a file the user wanted.
1136 Additionally, the file modes of extracted files and directories
1137 may have incorrect file bits, and the modification and access times may be
1138 wrong.
1139 .Pp
1140 If the creation of an archive is prematurely terminated by a signal or error,
1141 .Nm
1142 may have only partially created the archive which may violate the specific
1143 archive format specification.
1144 .Pp
1145 If while doing a
1146 .Em copy ,
1147 .Nm
1148 detects a file is about to overwrite itself, the file is not copied,
1149 a diagnostic message is written to
1150 .Dv standard error
1151 and when
1152 .Nm
1153 completes it will exit with a non-zero exit status.
1154 .Sh SEE ALSO
1155 .Xr cpio 1 ,
1156 .Xr tar 1
1157 .Sh STANDARDS
1158 The
1159 .Nm
1160 utility is a superset of the
1161 .St -p1003.2
1162 standard.
1163 The options
1164 .Fl z ,
1165 .Fl B ,
1166 .Fl D ,
1167 .Fl E ,
1168 .Fl G ,
1169 .Fl H ,
1170 .Fl L ,
1171 .Fl O ,
1172 .Fl P ,
1173 .Fl T ,
1174 .Fl U ,
1175 .Fl Y ,
1176 .Fl Z ,
1177 the archive formats
1178 .Ar bcpio ,
1179 .Ar sv4cpio ,
1180 .Ar sv4crc ,
1181 .Ar tar ,
1182 and the flawed archive handling during
1183 .Ar list
1184 and
1185 .Ar read
1186 operations are extensions to the
1187 .Tn POSIX
1188 standard.
1189 .Sh HISTORY
1190 The
1191 .Nm
1192 utility appeared in
1193 .Bx 4.4 .
1194 .Sh AUTHORS
1195 .An Keith Muller
1196 at the University of California, San Diego