Imported Debian patch 1.5-16
[debian/pax] / pax.1
1 .\"     $OpenBSD: pax.1,v 1.7 1998/09/23 00:13:49 aaron 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 cdjnvz
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 cdijknuvzDYZ
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 dijtuvzHLPX
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 The
296 .Ar directory
297 operand specifies a destination directory pathname.
298 If the
299 .Ar directory
300 operand does not exist, or it is not writable by the user,
301 or it is not of type directory,
302 .Nm pax
303 will exit with a non-zero exit status.
304 .Pp
305 The
306 .Ar pattern
307 operand is used to select one or more pathnames of archive members.
308 Archive members are selected using the pattern matching notation described
309 by
310 .Xr fnmatch 3 .
311 When the 
312 .Ar pattern
313 operand is not supplied, all members of the archive will be selected.
314 When a 
315 .Ar pattern
316 matches a directory, the entire file hierarchy rooted at that directory will
317 be selected.
318 When a
319 .Ar pattern
320 operand does not select at least one archive member,
321 .Nm pax
322 will write these
323 .Ar pattern
324 operands in a diagnostic message to
325 .Dv standard error
326 and then exit with a non-zero exit status.
327 .Pp
328 The
329 .Ar file
330 operand specifies the pathname of a file to be copied or archived.
331 When a
332 .Ar file
333 operand does not select at least one archive member,
334 .Nm pax
335 will write these
336 .Ar file
337 operand pathnames in a diagnostic message to
338 .Dv standard error
339 and then exit with a non-zero exit status.
340 .Sh OPTIONS
341 The following options are supported:
342 .Bl -tag -width 4n
343 .It Fl r
344 Read an archive file from
345 .Dv standard input
346 and extract the specified
347 .Ar files .
348 If any intermediate directories are needed in order to extract an archive
349 member, these directories will be created as if
350 .Xr mkdir 2
351 was called with the bitwise inclusive
352 .Dv OR 
353 of
354 .Dv S_IRWXU , S_IRWXG ,
355 and
356 .Dv S_IRWXO 
357 as the mode argument.
358 When the selected archive format supports the specification of linked
359 files and these files cannot be linked while the archive is being extracted,
360 .Nm pax
361 will write a diagnostic message to
362 .Dv standard error
363 and exit with a non-zero exit status at the completion of operation.
364 .It Fl w
365 Write files to the
366 .Dv standard output
367 in the specified archive format.
368 When no
369 .Ar file
370 operands are specified,
371 .Dv standard input
372 is read for a list of pathnames with one per line without any leading or
373 trailing
374 .Aq blanks .
375 .It Fl a
376 Append
377 .Ar files
378 to the end of an archive that was previously written.
379 If an archive format is not specified with a
380 .Fl x
381 option, the format currently being used in the archive will be selected.
382 Any attempt to append to an archive in a format different from the
383 format already used in the archive will cause 
384 .Nm pax
385 to exit immediately
386 with a non-zero exit status.
387 The blocking size used in the archive volume where writing starts
388 will continue to be used for the remainder of that archive volume.
389 .Pp
390 .Em Warning :
391 Many storage devices are not able to support the operations necessary
392 to perform an append operation.
393 Any attempt to append to an archive stored on such a device may damage the
394 archive or have other unpredictable results.
395 Tape drives in particular are more likely to not support an append operation.
396 An archive stored in a regular file system file or on a disk device will
397 usually support an append operation.
398 .It Fl b Ar blocksize
399 When
400 .Em writing
401 an archive,
402 block the output at a positive decimal integer number of
403 bytes per write to the archive file.
404 The
405 .Ar blocksize
406 must be a multiple of 512 bytes with a maximum of 64512 bytes.
407 Archives larger than 32256 bytes violate the
408 .Tn POSIX
409 standard and will not be portable to all systems.
410 A
411 .Ar blocksize
412 can end with
413 .Sq Li k
414 or
415 .Sq Li b
416 to specify multiplication by 1024 (1K) or 512, respectively.
417 A pair of
418 .Ar blocksizes
419 can be separated by
420 .Sq Li x
421 to indicate a product.
422 A specific archive device may impose additional restrictions on the size
423 of blocking it will support.
424 When blocking is not specified, the default 
425 .Ar blocksize
426 is dependent on the specific archive format being used (see the
427 .Fl x
428 option).
429 .It Fl c
430 Match all file or archive members
431 .Em except
432 those specified by the
433 .Ar pattern
434 and
435 .Ar file
436 operands.
437 .It Fl d
438 Cause files of type directory being copied or archived, or archive members of
439 type directory being extracted, to match only the directory file or archive
440 member and not the file hierarchy rooted at the directory.
441 .It Fl f Ar archive
442 Specify
443 .Ar archive
444 as the pathname of the input or output archive, overriding the default
445 .Dv standard input
446 (for
447 .Em list
448 and
449 .Em read )
450 or
451 .Dv standard output
452 (for
453 .Em write ) .
454 A single archive may span multiple files and different archive devices.
455 When required,
456 .Nm pax
457 will prompt for the pathname of the file or device of the next volume in the
458 archive.
459 .It Fl i
460 Interactively rename files or archive members.
461 For each archive member matching a
462 .Ar pattern
463 operand or each file matching a
464 .Ar file
465 operand,
466 .Nm pax
467 will prompt to
468 .Pa /dev/tty
469 giving the name of the file, its file mode and its modification time.
470 .Nm pax
471 will then read a line from
472 .Pa /dev/tty .
473 If this line is blank, the file or archive member is skipped.
474 If this line consists of a single period, the
475 file or archive member is processed with no modification to its name.
476 Otherwise, its name is replaced with the contents of the line.
477 .Nm pax
478 will immediately exit with a non-zero exit status if 
479 .Dv <EOF>
480 is encountered when reading a response or if
481 .Pa /dev/tty
482 cannot be opened for reading and writing.
483 .It Fl j
484 Filter archive through bzip2.
485 .It Fl k
486 Do not overwrite existing files.
487 .It Fl l
488 (The lowercase letter ``ell.'') Link files.
489 In the
490 .Em copy
491 mode
492 .Pq Fl r Fl w ,
493 hard links are made between the source and destination file hierarchies
494 whenever possible.
495 .It Fl n
496 Select the first archive member that matches each
497 .Ar pattern
498 operand.
499 No more than one archive member is matched for each
500 .Ar pattern .
501 When members of type directory are matched, the file hierarchy rooted at that
502 directory is also matched (unless
503 .Fl d 
504 is also specified).
505 .It Fl o Ar options
506 Information to modify the algorithm for extracting or writing archive files
507 which is specific to the archive format specified by
508 .Fl x .
509 In general,
510 .Ar options
511 take the form:
512 .Cm name=value .
513 .It Fl p Ar string
514 Specify one or more file characteristic options (privileges).
515 The
516 .Ar string
517 option-argument is a string specifying file characteristics to be retained or
518 discarded on extraction.
519 The string consists of the specification characters
520 .Cm a , e , m , o ,
521 and
522 .Cm p .
523 Multiple characteristics can be concatenated within the same string
524 and multiple
525 .Fl p 
526 options can be specified.
527 The meaning of the specification characters are as follows:
528 .Bl -tag -width 2n
529 .It Cm a
530 Do not preserve file access times.
531 By default, file access times are preserved whenever possible.
532 .It Cm e
533 .Sq Preserve everything ,
534 the user ID, group ID, file mode bits,
535 file access time, and file modification time.
536 This is intended to be used by
537 .Em root ,
538 someone with all the appropriate privileges, in order to preserve all
539 aspects of the files as they are recorded in the archive.
540 The 
541 .Cm e
542 flag is the sum of the
543 .Cm o 
544 and
545 .Cm p
546 flags.
547 .It Cm m
548 Do not preserve file modification times.
549 By default, file modification times are preserved whenever possible.
550 .It Cm o
551 Preserve the user ID and group ID.
552 .It Cm p
553 .Sq Preserve
554 the file mode bits.
555 This intended to be used by a
556 .Em user 
557 with regular privileges who wants to preserve all aspects of the file other
558 than the ownership.
559 The file times are preserved by default, but two other flags are offered to
560 disable this and use the time of extraction instead.
561 .El
562 .Pp
563 In the preceding list,
564 .Sq preserve
565 indicates that an attribute stored in the archive is given to the
566 extracted file, subject to the permissions of the invoking
567 process.
568 Otherwise the attribute of the extracted file is determined as
569 part of the normal file creation action.
570 If neither the 
571 .Cm e
572 nor the
573 .Cm o
574 specification character is specified, or the user ID and group ID are not
575 preserved for any reason,
576 .Nm pax
577 will not set the
578 .Dv S_ISUID 
579 .Em ( setuid )
580 and
581 .Dv S_ISGID
582 .Em ( setgid )
583 bits of the file mode.
584 If the preservation of any of these items fails for any reason,
585 .Nm pax
586 will write a diagnostic message to
587 .Dv standard error .
588 Failure to preserve these items will affect the final exit status,
589 but will not cause the extracted file to be deleted.
590 If the file characteristic letters in any of the string option-arguments are
591 duplicated or conflict with each other, the one(s) given last will take
592 precedence.
593 For example, if
594 .Dl Fl p Ar eme
595 is specified, file modification times are still preserved.
596 .It Fl s Ar replstr
597 Modify the file or archive member names specified by the
598 .Ar pattern
599 or
600 .Ar file
601 operands according to the substitution expression
602 .Ar replstr ,
603 using the syntax of the
604 .Xr ed 1
605 utility regular expressions.
606 The format of these regular expressions are:
607 .Dl /old/new/[gp]
608 As in
609 .Xr ed 1 ,
610 .Cm old
611 is a basic regular expression and
612 .Cm new
613 can contain an ampersand (&), \\n (where n is a digit) back-references,
614 or subexpression matching.
615 The
616 .Cm old
617 string may also contain
618 .Dv <newline>
619 characters.
620 Any non-null character can be used as a delimiter (/ is shown here).
621 Multiple
622 .Fl s
623 expressions can be specified.
624 The expressions are applied in the order they are specified on the
625 command line, terminating with the first successful substitution.
626 The optional trailing
627 .Cm g
628 continues to apply the substitution expression to the pathname substring
629 which starts with the first character following the end of the last successful
630 substitution. The first unsuccessful substitution stops the operation of the
631 .Cm g
632 option.
633 The optional trailing
634 .Cm p
635 will cause the final result of a successful substitution to be written to
636 .Dv standard error
637 in the following format:
638 .Dl <original pathname> >> <new pathname>
639 File or archive member names that substitute to the empty string
640 are not selected and will be skipped.
641 .It Fl t
642 Reset the access times of any file or directory read or accessed by
643 .Nm pax
644 to be the same as they were before being read or accessed by
645 .Nm pax .
646 .It Fl u
647 Ignore files that are older (having a less recent file modification time)
648 than a pre-existing file or archive member with the same name.
649 During
650 .Em read ,
651 an archive member with the same name as a file in the file system will be
652 extracted if the archive member is newer than the file.
653 During
654 .Em write ,
655 a file system member with the same name as an archive member will be
656 written to the archive if it is newer than the archive member.
657 During
658 .Em copy ,
659 the file in the destination hierarchy is replaced by the file in the source
660 hierarchy or by a link to the file in the source hierarchy if the file in
661 the source hierarchy is newer.
662 .It Fl v
663 During a
664 .Em list
665 operation, produce a verbose table of contents using the format of the
666 .Xr ls 1
667 utility with the
668 .Fl l
669 option.
670 For pathnames representing a hard link to a previous member of the archive,
671 the output has the format:
672 .Dl <ls -l listing> == <link name>
673 For pathnames representing a symbolic link, the output has the format:
674 .Dl <ls -l listing> => <link name>
675 Where <ls -l listing> is the output format specified by the 
676 .Xr ls 1
677 utility when used with the
678 .Fl l
679 option.
680 Otherwise for all the other operational modes
681 .Po Em read , write , Li and Em copy
682 .Pc ,
683 pathnames are written and flushed to
684 .Dv standard error
685 without a trailing
686 .Dv <newline>
687 as soon as processing begins on that file or
688 archive member.
689 The trailing
690 .Dv <newline> ,
691 is not buffered, and is written only after the file has been read or written.
692 .It Fl x Ar format
693 Specify the output archive format, with the default format being
694 .Ar ustar .
695 .Nm pax
696 currently supports the following formats:
697 .Bl -tag -width "sv4cpio"
698 .It Ar cpio
699 The extended cpio interchange format specified in the
700 .St -p1003.1
701 standard.
702 The default blocksize for this format is 5120 bytes.
703 Inode and device information about a file (used for detecting file hard links
704 by this format) which may be truncated by this format is detected by
705 .Nm pax
706 and is repaired.
707 .It Ar bcpio
708 The old binary cpio format.
709 The default blocksize for this format is 5120 bytes.
710 This format is not very portable and should not be used when other formats
711 are available.
712 Inode and device information about a file (used for detecting file hard links
713 by this format) which may be truncated by this format is detected by
714 .Nm pax
715 and is repaired.
716 .It Ar sv4cpio
717 The System V release 4 cpio.
718 The default blocksize for this format is 5120 bytes.
719 Inode and device information about a file (used for detecting file hard links
720 by this format) which may be truncated by this format is detected by
721 .Nm pax
722 and is repaired.
723 .It Ar sv4crc
724 The System V release 4 cpio with file crc checksums.
725 The default blocksize for this format is 5120 bytes.
726 Inode and device information about a file (used for detecting file hard links
727 by this format) which may be truncated by this format is detected by
728 .Nm pax
729 and is repaired.
730 .It Ar tar
731 The old BSD tar format as found in BSD4.3.
732 The default blocksize for this format is 10240 bytes.
733 Pathnames stored by this format must be 100 characters or less in length.
734 Only
735 .Em regular
736 files,
737 .Em  hard links , soft links ,
738 and
739 .Em  directories
740 will be archived (other file system types are not supported).
741 For backwards compatibility with even older tar formats, a
742 .Fl o
743 option can be used when writing an archive to omit the storage of directories.
744 This option takes the form:
745 .Dl Fl o Cm write_opt=nodir
746 .It Ar ustar
747 The extended tar interchange format specified in the
748 .St -p1003.1
749 standard.
750 The default blocksize for this format is 10240 bytes.
751 Pathnames stored by this format must be 250 characters or less in length.
752 .El
753 .Pp
754 .Nm pax
755 will detect and report any file that it is unable to store or extract
756 as the result of any specific archive format restrictions.
757 The individual archive formats may impose additional restrictions on use.
758 Typical archive format restrictions include (but are not limited to):
759 file pathname length, file size, link pathname length, and the type of the
760 file.
761 .It Fl j
762 Filter archive through bzip2.
763 .It Fl B Ar bytes
764 Limit the number of bytes written to a single archive volume to
765 .Ar bytes .
766 The
767 .Ar bytes
768 limit can end with
769 .Sq Li m ,
770 .Sq Li k ,
771 or
772 .Sq Li b
773 to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
774 A pair of
775 .Ar bytes
776 limits can be separated by
777 .Sq Li x
778 to indicate a product.
779 .Pp
780 .Em Warning :
781 Only use this option when writing an archive to a device which supports
782 an end of file read condition based on last (or largest) write offset
783 (such as a regular file or a tape drive). 
784 The use of this option with a floppy or hard disk is not recommended.
785 .It Fl D
786 This option is the same as the
787 .Fl u
788 option, except that the file inode change time is checked instead of the
789 file modification time.
790 The file inode change time can be used to select files whose inode information
791 (e.g. UID, GID, etc.) is newer than a copy of the file in the destination
792 .Ar directory .
793 .It Fl E Ar limit
794 Limit the number of consecutive read faults while trying to read a flawed
795 archive to
796 .Ar limit .
797 With a positive
798 .Ar limit ,
799 .Nm pax
800 will attempt to recover from an archive read error and will
801 continue processing starting with the next file stored in the archive.
802 A
803 .Ar limit
804 of 0 will cause
805 .Nm pax
806 to stop operation after the first read error is detected on an archive volume.
807 A
808 .Ar limit
809 of
810 .Li NONE
811 will cause
812 .Nm pax 
813 to attempt to recover from read errors forever.
814 The default 
815 .Ar limit
816 is a small positive number of retries.
817 .Pp
818 .Em Warning: 
819 Using this option with
820 .Li NONE
821 should be used with extreme caution as
822 .Nm pax
823 may get stuck in an infinite loop on a very badly flawed archive.
824 .It Fl G Ar group
825 Select a file based on its
826 .Ar group
827 name, or when starting with a
828 .Cm # ,
829 a numeric gid.
830 A '\\' can be used to escape the
831 .Cm # .
832 Multiple 
833 .Fl G
834 options may be supplied and checking stops with the first match.
835 .It Fl H
836 Follow only command line symbolic links while performing a physical file
837 system traversal.
838 .It Fl L
839 Follow all symbolic links to perform a logical file system traversal.
840 .It Fl P
841 Do not follow symbolic links, perform a physical file system traversal.
842 This is the default mode.
843 .It Fl T Ar [from_date][,to_date][/[c][m]]
844 Allow files to be selected based on a file modification or inode change
845 time falling within a specified time range of 
846 .Ar from_date
847 to
848 .Ar to_date
849 (the dates are inclusive).
850 If only a 
851 .Ar from_date
852 is supplied, all files with a modification or inode change time
853 equal to or younger are selected.
854 If only a
855 .Ar to_date
856 is supplied, all files with a modification or inode change time
857 equal to or older will be selected.
858 When the 
859 .Ar from_date
860 is equal to the
861 .Ar to_date ,
862 only files with a modification or inode change time of exactly that
863 time will be selected.
864 .Pp
865 When
866 .Nm pax
867 is in the 
868 .Em write
869 or
870 .Em copy
871 mode, the optional trailing field
872 .Ar [c][m]
873 can be used to determine which file time (inode change, file modification or
874 both) are used in the comparison.
875 If neither is specified, the default is to use file modification time only.
876 The
877 .Ar m
878 specifies the comparison of file modification time (the time when
879 the file was last written).
880 The
881 .Ar c
882 specifies the comparison of inode change time (the time when the file
883 inode was last changed; e.g. a change of owner, group, mode, etc).
884 When 
885 .Ar c
886 and
887 .Ar m
888 are both specified, then the modification and inode change times are
889 both compared.
890 The inode change time comparison is useful in selecting files whose
891 attributes were recently changed or selecting files which were recently
892 created and had their modification time reset to an older time (as what
893 happens when a file is extracted from an archive and the modification time
894 is preserved).
895 Time comparisons using both file times is useful when
896 .Nm pax
897 is used to create a time based incremental archive (only files that were
898 changed during a specified time range will be archived).
899 .Pp
900 A time range is made up of six different fields and each field must contain two
901 digits.
902 The format is:
903 .Dl [yy[mm[dd[hh]]]]mm[.ss]
904 Where
905 .Cm yy
906 is the last two digits of the year,
907 the first
908 .Cm mm
909 is the month (from 01 to 12),
910 .Cm dd
911 is the day of the month (from 01 to 31),
912 .Cm hh
913 is the hour of the day (from 00 to 23),
914 the second
915 .Cm mm
916 is the minute (from 00 to 59),
917 and
918 .Cm ss
919 is the seconds (from 00 to 59).
920 The minute field
921 .Cm mm
922 is required, while the other fields are optional and must be added in the
923 following order:
924 .Dl Cm hh , dd , mm , yy .
925 The 
926 .Cm ss
927 field may be added independently of the other fields.
928 Time ranges are relative to the current time, so
929 .Dl Fl T Ar 1234/cm
930 would select all files with a modification or inode change time
931 of 12:34 PM today or later.
932 Multiple 
933 .Fl T
934 time range can be supplied and checking stops with the first match.
935 .It Fl U Ar user
936 Select a file based on its
937 .Ar user
938 name, or when starting with a
939 .Cm # ,
940 a numeric UID.
941 A '\\' can be used to escape the
942 .Cm # .
943 Multiple 
944 .Fl U
945 options may be supplied and checking stops with the first match.
946 .It Fl X
947 When traversing the file hierarchy specified by a pathname,
948 do not descend into directories that have a different device ID.
949 See the
950 .Li st_dev 
951 field as described in
952 .Xr stat 2
953 for more information about device IDs.
954 .It Fl Y
955 This option is the same as the
956 .Fl D
957 option, except that the inode change time is checked using the
958 pathname created after all the file name modifications have completed.
959 .It Fl Z
960 This option is the same as the
961 .Fl u
962 option, except that the modification time is checked using the
963 pathname created after all the file name modifications have completed.
964 .El
965 .Pp
966 The options that operate on the names of files or archive members
967 .Po Fl c ,
968 .Fl i ,
969 .Fl n ,
970 .Fl s ,
971 .Fl u ,
972 .Fl v ,
973 .Fl D ,
974 .Fl G ,
975 .Fl T ,
976 .Fl U ,
977 .Fl Y ,
978 and
979 .Fl Z
980 .Pc
981 interact as follows.
982 .Pp
983 When extracting files during a
984 .Em read
985 operation, archive members are
986 .Sq selected ,
987 based only on the user specified pattern operands as modified by the
988 .Fl c ,
989 .Fl n ,
990 .Fl u ,
991 .Fl D ,
992 .Fl G ,
993 .Fl T ,
994 .Fl U
995 options.
996 Then any
997 .Fl s
998 and
999 .Fl i
1000 options will modify in that order, the names of these selected files.
1001 Then the
1002 .Fl Y
1003 and
1004 .Fl Z
1005 options will be applied based on the final pathname.
1006 Finally, the 
1007 .Fl v
1008 option will write the names resulting from these modifications.
1009 .Pp
1010 When archiving files during a
1011 .Em write
1012 operation, or copying files during a
1013 .Em copy
1014 operation, archive members are
1015 .Sq selected ,
1016 based only on the user specified pathnames as modified by the
1017 .Fl n ,
1018 .Fl u ,
1019 .Fl D ,
1020 .Fl G ,
1021 .Fl T ,
1022 and 
1023 .Fl U
1024 options (the
1025 .Fl D
1026 option only applies during a copy operation).
1027 Then any
1028 .Fl s 
1029 and
1030 .Fl i
1031 options will modify in that order, the names of these selected files.
1032 Then during a
1033 .Em copy
1034 operation the
1035 .Fl Y
1036 and the
1037 .Fl Z
1038 options will be applied based on the final pathname.
1039 Finally, the
1040 .Fl v
1041 option will write the names resulting from these modifications.
1042 .Pp
1043 When one or both of the
1044 .Fl u
1045 or
1046 .Fl D
1047 options are specified along with the
1048 .Fl n
1049 option, a file is not considered selected unless it is newer
1050 than the file to which it is compared.
1051 .Sh EXAMPLES
1052 The command:
1053 .Dl pax -w -f /dev/rst0 .\ 
1054 copies the contents of the current directory to the device
1055 .Pa /dev/rst0 .
1056 .Pp
1057 The command:
1058 .Dl pax -v -f filename
1059 gives the verbose table of contents for an archive stored in
1060 .Pa filename .
1061 .Pp
1062 The following commands:
1063 .Dl mkdir newdir
1064 .Dl cd olddir
1065 .Dl pax -rw .\ newdir
1066 will copy the entire
1067 .Pa olddir
1068 directory hierarchy to
1069 .Pa newdir .
1070 .Pp
1071 The command:
1072 .Dl pax -r -s ',^//*usr//*,,' -f a.pax
1073 reads the archive 
1074 .Pa a.pax ,
1075 with all files rooted in ``/usr'' into the archive extracted relative to the
1076 current directory.
1077 .Pp
1078 The command:
1079 .Dl pax -rw -i .\ dest_dir
1080 can be used to interactively select the files to copy from the current
1081 directory to
1082 .Pa dest_dir .
1083 .Pp
1084 The command:
1085 .Dl pax -r -pe -U root -G bin -f a.pax
1086 will extract all files from the archive
1087 .Pa a.pax
1088 which are owned by
1089 .Em root
1090 with group
1091 .Em bin
1092 and will preserve all file permissions.
1093 .Pp
1094 The command:
1095 .Dl pax -r -w -v -Y -Z home /backup
1096 will update (and list) only those files in the destination directory
1097 .Pa /backup
1098 which are older (less recent inode change or file modification times) than
1099 files with the same name found in the source file tree
1100 .Pa home .
1101 .Sh STANDARDS
1102 The
1103 .Nm pax
1104 utility is a superset of the
1105 .St -p1003.1
1106 standard.
1107 The options
1108 .Fl j ,
1109 .Fl z ,
1110 .Fl B ,
1111 .Fl D ,
1112 .Fl E ,
1113 .Fl G ,
1114 .Fl H ,
1115 .Fl L ,
1116 .Fl P ,
1117 .Fl T ,
1118 .Fl U ,
1119 .Fl Y ,
1120 .Fl Z ,
1121 the archive formats
1122 .Ar bcpio ,
1123 .Ar sv4cpio ,
1124 .Ar sv4crc ,
1125 .Ar tar ,
1126 and the flawed archive handling during
1127 .Ar list
1128 and
1129 .Ar read
1130 operations are extensions to the
1131 .Tn POSIX
1132 standard.
1133 .Sh SEE ALSO
1134 .Xr cpio 1 ,
1135 .Xr tar 1
1136 .Sh AUTHOR
1137 Keith Muller at the University of California, San Diego.
1138 .Sh ERRORS
1139 .Nm pax
1140 will exit with one of the following values:
1141 .Bl -tag -width 2n
1142 .It 0
1143 All files were processed successfully.
1144 .It 1 
1145 An error occurred.
1146 .El
1147 .Pp
1148 Whenever
1149 .Nm pax
1150 cannot create a file or a link when reading an archive or cannot
1151 find a file when writing an archive, or cannot preserve the user ID,
1152 group ID, or file mode when the
1153 .Fl p
1154 option is specified, a diagnostic message is written to
1155 .Dv standard error
1156 and a non-zero exit status will be returned, but processing will continue.
1157 In the case where
1158 .Nm pax
1159 cannot create a link to a file,
1160 .Nm pax
1161 will not create a second copy of the file.
1162 .Pp
1163 If the extraction of a file from an archive is prematurely terminated by
1164 a signal or error,
1165 .Nm pax
1166 may have only partially extracted a file the user wanted.
1167 Additionally, the file modes of extracted files and directories
1168 may have incorrect file bits, and the modification and access times may be
1169 wrong.
1170 .Pp
1171 If the creation of an archive is prematurely terminated by a signal or error,
1172 .Nm pax
1173 may have only partially created the archive which may violate the specific
1174 archive format specification.
1175 .Pp
1176 If while doing a
1177 .Em copy ,
1178 .Nm pax
1179 detects a file is about to overwrite itself, the file is not copied,
1180 a diagnostic message is written to
1181 .Dv standard error
1182 and when
1183 .Nm pax
1184 completes it will exit with a non-zero exit status.