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