acfb48979ad27aad7e7572cb31509665ff56ee9d
[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 cdnv
50 .Bk -words
51 .Op Fl f Ar archive
52 .Ek
53 .Bk -words
54 .Op Fl s Ar replstr
55 .Ar ...
56 .Ek
57 .Bk -words
58 .Op Fl U Ar user
59 .Ar ...
60 .Ek
61 .Bk -words
62 .Op Fl G Ar group
63 .Ar ...
64 .Ek
65 .Bk -words
66 .Oo
67 .Fl T
68 .Op Ar from_date
69 .Op Ar ,to_date
70 .Oc
71 .Ar ...
72 .Ek
73 .Op Ar pattern ...
74 .Nm pax
75 .Fl r
76 .Op Fl cdiknuvDYZ
77 .Bk -words
78 .Op Fl f Ar archive
79 .Ek
80 .Bk -words
81 .Op Fl o Ar options
82 .Ar ...
83 .Ek
84 .Bk -words
85 .Op Fl p Ar string
86 .Ar ...
87 .Ek
88 .Bk -words
89 .Op Fl s Ar replstr
90 .Ar ...
91 .Ek
92 .Op Fl E Ar limit
93 .Bk -words
94 .Op Fl U Ar user
95 .Ar ...
96 .Ek
97 .Bk -words
98 .Op Fl G Ar group
99 .Ar ...
100 .Ek
101 .Bk -words
102 .Oo
103 .Fl T
104 .Op Ar from_date
105 .Op Ar ,to_date
106 .Oc
107 .Ar ...
108 .Ek
109 .Op Ar pattern ...
110 .Nm pax
111 .Fl w
112 .Op Fl dituvHLPX
113 .Bk -words
114 .Op Fl b Ar blocksize
115 .Ek
116 .Oo
117 .Op Fl a
118 .Op Fl f Ar archive
119 .Oc
120 .Bk -words
121 .Op Fl x Ar format
122 .Ek
123 .Bk -words
124 .Op Fl s Ar replstr
125 .Ar ...
126 .Ek
127 .Bk -words
128 .Op Fl o Ar options
129 .Ar ...
130 .Ek
131 .Bk -words
132 .Op Fl U Ar user
133 .Ar ...
134 .Ek
135 .Bk -words
136 .Op Fl G Ar group
137 .Ar ...
138 .Ek
139 .Bk -words
140 .Op Fl B Ar bytes
141 .Ek
142 .Bk -words
143 .Oo
144 .Fl T
145 .Op Ar from_date
146 .Op Ar ,to_date
147 .Op Ar /[c][m]
148 .Oc
149 .Ar ...
150 .Ek
151 .Op Ar file ...
152 .Nm pax
153 .Fl r
154 .Fl w
155 .Op Fl diklntuvDHLPXYZ
156 .Bk -words
157 .Op Fl p Ar string
158 .Ar ...
159 .Ek
160 .Bk -words
161 .Op Fl s Ar replstr
162 .Ar ...
163 .Ek
164 .Bk -words
165 .Op Fl U Ar user
166 .Ar ...
167 .Ek
168 .Bk -words
169 .Op Fl G Ar group
170 .Ar ...
171 .Ek
172 .Bk -words
173 .Oo
174 .Fl T
175 .Op Ar from_date
176 .Op Ar ,to_date
177 .Op Ar /[c][m]
178 .Oc
179 .Ar ...
180 .Ek
181 .Op Ar file ...
182 .Ar directory
183 .Sh DESCRIPTION
184 .Nm pax
185 will read, write, and list the members of an archive file,
186 and will copy directory hierarchies.
187 .Nm pax 
188 operation is independent of the specific archive format,
189 and supports a wide variety of different archive formats.
190 A list of supported archive formats can be found under the description of the
191 .Fl x
192 option.
193 .Pp
194 The presence of the
195 .Fl r
196 and the
197 .Fl w
198 options specifies which of the following functional modes
199 .Nm pax
200 will operate under:
201 .Em list , read , write ,
202 and
203 .Em copy .
204 .Bl -tag -width 6n
205 .It <none>
206 .Em List .
207 .Nm pax
208 will write to
209 .Dv standard output
210 a table of contents of the members of the archive file read from
211 .Dv standard input ,
212 whose pathnames match the specified
213 .Ar patterns .
214 The table of contents contains one filename per line
215 and is written using single line buffering.
216 .It Fl r
217 .Em Read .
218 .Nm pax
219 extracts the members of the archive file read from the
220 .Dv standard input ,
221 with pathnames matching the specified 
222 .Ar patterns .
223 The archive format and blocking is automatically determined on input.
224 When an extracted file is a directory, the entire file hierarchy
225 rooted at that directory is extracted.
226 All extracted files are created relative to the current file hierarchy.
227 The setting of ownership, access and modification times, and file mode of
228 the extracted files are discussed in more detail under the
229 .Fl p
230 option.
231 .It Fl w
232 .Em Write .
233 .Nm pax
234 writes an archive containing the 
235 .Ar file
236 operands to
237 .Dv standard output
238 using the specified archive format.
239 When no 
240 .Ar file
241 operands are specified, a list of files to copy with one per line is read from 
242 .Dv standard input .
243 When a 
244 .Ar file
245 operand is also a directory, the entire file hierarchy rooted
246 at that directory will be included.
247 .It Fl r Fl w
248 .Em Copy .
249 .Nm pax
250 copies the
251 .Ar file
252 operands to the destination
253 .Ar directory .
254 When no 
255 .Ar file
256 operands are specified, a list of files to copy with one per line is read from
257 the
258 .Dv standard input .
259 When a
260 .Ar file
261 operand is also a directory the entire file
262 hierarchy rooted at that directory will be included.
263 The effect of the
264 .Em copy
265 is as if the copied files were written to an archive file and then
266 subsequently extracted, except that there may be hard links between
267 the original and the copied files (see the
268 .Fl l
269 option below).
270 .Pp
271 .Em Warning :
272 The destination
273 .Ar directory
274 must not be one of the
275 .Ar file
276 operands or a member of a file hierarchy rooted at one of the
277 .Ar file
278 operands.
279 The result of a
280 .Em copy
281 under these conditions is unpredictable.
282 .El
283 .Pp
284 While processing a damaged archive during a
285 .Em read
286 or
287 .Em list
288 operation,
289 .Nm pax
290 will attempt to recover from media defects and will search through the archive
291 to locate and process the largest number of archive members possible (see the
292 .Fl E
293 option for more details on error handling).
294 .Sh OPERANDS
295 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 k
484 Do not overwrite existing files.
485 .It Fl l
486 (The lowercase letter ``ell.'') Link files.
487 In the
488 .Em copy
489 mode
490 .Pq Fl r Fl w ,
491 hard links are made between the source and destination file hierarchies
492 whenever possible.
493 .It Fl n
494 Select the first archive member that matches each
495 .Ar pattern
496 operand.
497 No more than one archive member is matched for each
498 .Ar pattern .
499 When members of type directory are matched, the file hierarchy rooted at that
500 directory is also matched (unless
501 .Fl d 
502 is also specified).
503 .It Fl o Ar options
504 Information to modify the algorithm for extracting or writing archive files
505 which is specific to the archive format specified by
506 .Fl x .
507 In general,
508 .Ar options
509 take the form:
510 .Cm name=value .
511 .It Fl p Ar string
512 Specify one or more file characteristic options (privileges).
513 The
514 .Ar string
515 option-argument is a string specifying file characteristics to be retained or
516 discarded on extraction.
517 The string consists of the specification characters
518 .Cm a , e , m , o ,
519 and
520 .Cm p .
521 Multiple characteristics can be concatenated within the same string
522 and multiple
523 .Fl p 
524 options can be specified.
525 The meaning of the specification characters are as follows:
526 .Bl -tag -width 2n
527 .It Cm a
528 Do not preserve file access times.
529 By default, file access times are preserved whenever possible.
530 .It Cm e
531 .Sq Preserve everything ,
532 the user ID, group ID, file mode bits,
533 file access time, and file modification time.
534 This is intended to be used by
535 .Em root ,
536 someone with all the appropriate privileges, in order to preserve all
537 aspects of the files as they are recorded in the archive.
538 The 
539 .Cm e
540 flag is the sum of the
541 .Cm o 
542 and
543 .Cm p
544 flags.
545 .It Cm m
546 Do not preserve file modification times.
547 By default, file modification times are preserved whenever possible.
548 .It Cm o
549 Preserve the user ID and group ID.
550 .It Cm p
551 .Sq Preserve
552 the file mode bits.
553 This intended to be used by a
554 .Em user 
555 with regular privileges who wants to preserve all aspects of the file other
556 than the ownership.
557 The file times are preserved by default, but two other flags are offered to
558 disable this and use the time of extraction instead.
559 .El
560 .Pp
561 In the preceding list,
562 .Sq preserve
563 indicates that an attribute stored in the archive is given to the
564 extracted file, subject to the permissions of the invoking
565 process.
566 Otherwise the attribute of the extracted file is determined as
567 part of the normal file creation action.
568 If neither the 
569 .Cm e
570 nor the
571 .Cm o
572 specification character is specified, or the user ID and group ID are not
573 preserved for any reason,
574 .Nm pax
575 will not set the
576 .Dv S_ISUID 
577 .Em ( setuid )
578 and
579 .Dv S_ISGID
580 .Em ( setgid )
581 bits of the file mode.
582 If the preservation of any of these items fails for any reason,
583 .Nm pax
584 will write a diagnostic message to
585 .Dv standard error .
586 Failure to preserve these items will affect the final exit status,
587 but will not cause the extracted file to be deleted.
588 If the file characteristic letters in any of the string option-arguments are
589 duplicated or conflict with each other, the one(s) given last will take
590 precedence.
591 For example, if
592 .Dl Fl p Ar eme
593 is specified, file modification times are still preserved.
594 .It Fl s Ar replstr
595 Modify the file or archive member names specified by the
596 .Ar pattern
597 or
598 .Ar file
599 operands according to the substitution expression
600 .Ar replstr ,
601 using the syntax of the
602 .Xr ed 1
603 utility regular expressions.
604 The format of these regular expressions are:
605 .Dl /old/new/[gp]
606 As in
607 .Xr ed 1 ,
608 .Cm old
609 is a basic regular expression and
610 .Cm new
611 can contain an ampersand (&), \\n (where n is a digit) back-references,
612 or subexpression matching.
613 The
614 .Cm old
615 string may also contain
616 .Dv <newline>
617 characters.
618 Any non-null character can be used as a delimiter (/ is shown here).
619 Multiple
620 .Fl s
621 expressions can be specified.
622 The expressions are applied in the order they are specified on the
623 command line, terminating with the first successful substitution.
624 The optional trailing
625 .Cm g
626 continues to apply the substitution expression to the pathname substring
627 which starts with the first character following the end of the last successful
628 substitution. The first unsuccessful substitution stops the operation of the
629 .Cm g
630 option.
631 The optional trailing
632 .Cm p
633 will cause the final result of a successful substitution to be written to
634 .Dv standard error
635 in the following format:
636 .Dl <original pathname> >> <new pathname>
637 File or archive member names that substitute to the empty string
638 are not selected and will be skipped.
639 .It Fl t
640 Reset the access times of any file or directory read or accessed by
641 .Nm pax
642 to be the same as they were before being read or accessed by
643 .Nm pax .
644 .It Fl u
645 Ignore files that are older (having a less recent file modification time)
646 than a pre-existing file or archive member with the same name.
647 During
648 .Em read ,
649 an archive member with the same name as a file in the file system will be
650 extracted if the archive member is newer than the file.
651 During
652 .Em write ,
653 a file system member with the same name as an archive member will be
654 written to the archive if it is newer than the archive member.
655 During
656 .Em copy ,
657 the file in the destination hierarchy is replaced by the file in the source
658 hierarchy or by a link to the file in the source hierarchy if the file in
659 the source hierarchy is newer.
660 .It Fl v
661 During a
662 .Em list
663 operation, produce a verbose table of contents using the format of the
664 .Xr ls 1
665 utility with the
666 .Fl l
667 option.
668 For pathnames representing a hard link to a previous member of the archive,
669 the output has the format:
670 .Dl <ls -l listing> == <link name>
671 For pathnames representing a symbolic link, the output has the format:
672 .Dl <ls -l listing> => <link name>
673 Where <ls -l listing> is the output format specified by the 
674 .Xr ls 1
675 utility when used with the
676 .Fl l
677 option.
678 Otherwise for all the other operational modes
679 .Po Em read , write , Li and Em copy
680 .Pc ,
681 pathnames are written and flushed to
682 .Dv standard error
683 without a trailing
684 .Dv <newline>
685 as soon as processing begins on that file or
686 archive member.
687 The trailing
688 .Dv <newline> ,
689 is not buffered, and is written only after the file has been read or written.
690 .It Fl x Ar format
691 Specify the output archive format, with the default format being
692 .Ar ustar .
693 .Nm pax
694 currently supports the following formats:
695 .Bl -tag -width "sv4cpio"
696 .It Ar cpio
697 The extended cpio interchange format specified in the
698 .St -p1003.2
699 standard.
700 The default blocksize for this format is 5120 bytes.
701 Inode and device information about a file (used for detecting file hard links
702 by this format) which may be truncated by this format is detected by
703 .Nm pax
704 and is repaired.
705 .It Ar bcpio
706 The old binary cpio format.
707 The default blocksize for this format is 5120 bytes.
708 This format is not very portable and should not be used when other formats
709 are available.
710 Inode and device information about a file (used for detecting file hard links
711 by this format) which may be truncated by this format is detected by
712 .Nm pax
713 and is repaired.
714 .It Ar sv4cpio
715 The System V release 4 cpio.
716 The default blocksize for this format is 5120 bytes.
717 Inode and device information about a file (used for detecting file hard links
718 by this format) which may be truncated by this format is detected by
719 .Nm pax
720 and is repaired.
721 .It Ar sv4crc
722 The System V release 4 cpio with file crc checksums.
723 The default blocksize for this format is 5120 bytes.
724 Inode and device information about a file (used for detecting file hard links
725 by this format) which may be truncated by this format is detected by
726 .Nm pax
727 and is repaired.
728 .It Ar tar
729 The old BSD tar format as found in BSD4.3.
730 The default blocksize for this format is 10240 bytes.
731 Pathnames stored by this format must be 100 characters or less in length.
732 Only
733 .Em regular
734 files,
735 .Em  hard links , soft links ,
736 and
737 .Em  directories
738 will be archived (other file system types are not supported).
739 For backwards compatibility with even older tar formats, a
740 .Fl o
741 option can be used when writing an archive to omit the storage of directories.
742 This option takes the form:
743 .Dl Fl o Cm write_opt=nodir
744 .It Ar ustar
745 The extended tar interchange format specified in the
746 .St -p1003.2
747 standard.
748 The default blocksize for this format is 10240 bytes.
749 Pathnames stored by this format must be 250 characters or less in length.
750 .El
751 .Pp
752 .Nm pax
753 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
758 file.
759 .It Fl B Ar bytes
760 Limit the number of bytes written to a single archive volume to
761 .Ar bytes .
762 The
763 .Ar bytes
764 limit can end with
765 .Sq Li m ,
766 .Sq Li k ,
767 or
768 .Sq Li b
769 to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
770 A pair of
771 .Ar bytes
772 limits can be separated by
773 .Sq Li x
774 to indicate a product.
775 .Pp
776 .Em Warning :
777 Only use this option when writing an archive to a device which supports
778 an end of file read condition based on last (or largest) write offset
779 (such as a regular file or a tape drive). 
780 The use of this option with a floppy or hard disk is not recommended.
781 .It Fl D
782 This option is the same as the
783 .Fl u
784 option, except that the file inode change time is checked instead of the
785 file modification time.
786 The file inode change time can be used to select files whose inode information
787 (e.g. UID, GID, etc.) is newer than a copy of the file in the destination
788 .Ar directory .
789 .It Fl E Ar limit
790 Limit the number of consecutive read faults while trying to read a flawed
791 archive to
792 .Ar limit .
793 With a positive
794 .Ar limit ,
795 .Nm pax
796 will attempt to recover from an archive read error and will
797 continue processing starting with the next file stored in the archive.
798 A
799 .Ar limit
800 of 0 will cause
801 .Nm pax
802 to stop operation after the first read error is detected on an archive volume.
803 A
804 .Ar limit
805 of
806 .Li NONE
807 will cause
808 .Nm pax 
809 to attempt to recover from read errors forever.
810 The default 
811 .Ar limit
812 is a small positive number of retries.
813 .Pp
814 .Em Warning: 
815 Using this option with
816 .Li NONE
817 should be used with extreme caution as
818 .Nm pax
819 may get stuck in an infinite loop on a very badly flawed archive.
820 .It Fl G Ar group
821 Select a file based on its
822 .Ar group
823 name, or when starting with a
824 .Cm # ,
825 a numeric gid.
826 A '\\' can be used to escape the
827 .Cm # .
828 Multiple 
829 .Fl G
830 options may be supplied and checking stops with the first match.
831 .It Fl H
832 Follow only command line symbolic links while performing a physical file
833 system traversal.
834 .It Fl L
835 Follow all symbolic links to perform a logical file system traversal.
836 .It Fl P
837 Do not follow symbolic links, perform a physical file system traversal.
838 This is the default mode.
839 .It Fl T Ar [from_date][,to_date][/[c][m]]
840 Allow files to be selected based on a file modification or inode change
841 time falling within a specified time range of 
842 .Ar from_date
843 to
844 .Ar to_date
845 (the dates are inclusive).
846 If only a 
847 .Ar from_date
848 is supplied, all files with a modification or inode change time
849 equal to or younger are selected.
850 If only a
851 .Ar to_date
852 is supplied, all files with a modification or inode change time
853 equal to or older will be selected.
854 When the 
855 .Ar from_date
856 is equal to the
857 .Ar to_date ,
858 only files with a modification or inode change time of exactly that
859 time will be selected.
860 .Pp
861 When
862 .Nm pax
863 is in the 
864 .Em write
865 or
866 .Em copy
867 mode, the optional trailing field
868 .Ar [c][m]
869 can be used to determine which file time (inode change, file modification or
870 both) are used in the comparison.
871 If neither is specified, the default is to use file modification time only.
872 The
873 .Ar m
874 specifies the comparison of file modification time (the time when
875 the file was last written).
876 The
877 .Ar c
878 specifies the comparison of inode change time (the time when the file
879 inode was last changed; e.g. a change of owner, group, mode, etc).
880 When 
881 .Ar c
882 and
883 .Ar m
884 are both specified, then the modification and inode change times are
885 both compared.
886 The inode change time comparison is useful in selecting files whose
887 attributes were recently changed or selecting files which were recently
888 created and had their modification time reset to an older time (as what
889 happens when a file is extracted from an archive and the modification time
890 is preserved).
891 Time comparisons using both file times is useful when
892 .Nm pax
893 is used to create a time based incremental archive (only files that were
894 changed during a specified time range will be archived).
895 .Pp
896 A time range is made up of six different fields and each field must contain two
897 digits.
898 The format is:
899 .Dl [yy[mm[dd[hh]]]]mm[.ss]
900 Where
901 .Cm yy
902 is the last two digits of the year,
903 the first
904 .Cm mm
905 is the month (from 01 to 12),
906 .Cm dd
907 is the day of the month (from 01 to 31),
908 .Cm hh
909 is the hour of the day (from 00 to 23),
910 the second
911 .Cm mm
912 is the minute (from 00 to 59),
913 and
914 .Cm ss
915 is the seconds (from 00 to 59).
916 The minute field
917 .Cm mm
918 is required, while the other fields are optional and must be added in the
919 following order:
920 .Dl Cm hh , dd , mm , yy .
921 The 
922 .Cm ss
923 field may be added independently of the other fields.
924 Time ranges are relative to the current time, so
925 .Dl Fl T Ar 1234/cm
926 would select all files with a modification or inode change time
927 of 12:34 PM today or later.
928 Multiple 
929 .Fl T
930 time range can be supplied and checking stops with the first match.
931 .It Fl U Ar user
932 Select a file based on its
933 .Ar user
934 name, or when starting with a
935 .Cm # ,
936 a numeric UID.
937 A '\\' can be used to escape the
938 .Cm # .
939 Multiple 
940 .Fl U
941 options may be supplied and checking stops with the first match.
942 .It Fl X
943 When traversing the file hierarchy specified by a pathname,
944 do not descend into directories that have a different device ID.
945 See the
946 .Li st_dev 
947 field as described in
948 .Xr stat 2
949 for more information about device IDs.
950 .It Fl Y
951 This option is the same as the
952 .Fl D
953 option, except that the inode change time is checked using the
954 pathname created after all the file name modifications have completed.
955 .It Fl Z
956 This option is the same as the
957 .Fl u
958 option, except that the modification time is checked using the
959 pathname created after all the file name modifications have completed.
960 .El
961 .Pp
962 The options that operate on the names of files or archive members
963 .Po Fl c ,
964 .Fl i ,
965 .Fl n ,
966 .Fl s ,
967 .Fl u ,
968 .Fl v ,
969 .Fl D ,
970 .Fl G ,
971 .Fl T ,
972 .Fl U ,
973 .Fl Y ,
974 and
975 .Fl Z
976 .Pc
977 interact as follows.
978 .Pp
979 When extracting files during a
980 .Em read
981 operation, archive members are
982 .Sq selected ,
983 based only on the user specified pattern operands as modified by the
984 .Fl c ,
985 .Fl n ,
986 .Fl u ,
987 .Fl D ,
988 .Fl G ,
989 .Fl T ,
990 .Fl U
991 options.
992 Then any
993 .Fl s
994 and
995 .Fl i
996 options will modify in that order, the names of these selected files.
997 Then the
998 .Fl Y
999 and
1000 .Fl Z
1001 options will be applied based on the final pathname.
1002 Finally, the 
1003 .Fl v
1004 option will write the names resulting from these modifications.
1005 .Pp
1006 When archiving files during a
1007 .Em write
1008 operation, or copying files during a
1009 .Em copy
1010 operation, archive members are
1011 .Sq selected ,
1012 based only on the user specified pathnames as modified by the
1013 .Fl n ,
1014 .Fl u ,
1015 .Fl D ,
1016 .Fl G ,
1017 .Fl T ,
1018 and 
1019 .Fl U
1020 options (the
1021 .Fl D
1022 option only applies during a copy operation).
1023 Then any
1024 .Fl s 
1025 and
1026 .Fl i
1027 options will modify in that order, the names of these selected files.
1028 Then during a
1029 .Em copy
1030 operation the
1031 .Fl Y
1032 and the
1033 .Fl Z
1034 options will be applied based on the final pathname.
1035 Finally, the
1036 .Fl v
1037 option will write the names resulting from these modifications.
1038 .Pp
1039 When one or both of the
1040 .Fl u
1041 or
1042 .Fl D
1043 options are specified along with the
1044 .Fl n
1045 option, a file is not considered selected unless it is newer
1046 than the file to which it is compared.
1047 .Sh EXAMPLES
1048 The command:
1049 .Dl pax -w -f /dev/rst0 .\ 
1050 copies the contents of the current directory to the device
1051 .Pa /dev/rst0 .
1052 .Pp
1053 The command:
1054 .Dl pax -v -f filename
1055 gives the verbose table of contents for an archive stored in
1056 .Pa filename .
1057 .Pp
1058 The following commands:
1059 .Dl mkdir newdir
1060 .Dl cd olddir
1061 .Dl pax -rw .\ newdir
1062 will copy the entire
1063 .Pa olddir
1064 directory hierarchy to
1065 .Pa newdir .
1066 .Pp
1067 The command:
1068 .Dl pax -r -s ',^//*usr//*,,' -f a.pax
1069 reads the archive 
1070 .Pa a.pax ,
1071 with all files rooted in ``/usr'' into the archive extracted relative to the
1072 current directory.
1073 .Pp
1074 The command:
1075 .Dl pax -rw -i .\ dest_dir
1076 can be used to interactively select the files to copy from the current
1077 directory to
1078 .Pa dest_dir .
1079 .Pp
1080 The command:
1081 .Dl pax -r -pe -U root -G bin -f a.pax
1082 will extract all files from the archive
1083 .Pa a.pax
1084 which are owned by
1085 .Em root
1086 with group
1087 .Em bin
1088 and will preserve all file permissions.
1089 .Pp
1090 The command:
1091 .Dl pax -r -w -v -Y -Z home /backup
1092 will update (and list) only those files in the destination directory
1093 .Pa /backup
1094 which are older (less recent inode change or file modification times) than
1095 files with the same name found in the source file tree
1096 .Pa home .
1097 .Sh STANDARDS
1098 The
1099 .Nm pax
1100 utility is a superset of the
1101 .St -p1003.2
1102 standard.
1103 The options
1104 .Fl B ,
1105 .Fl D ,
1106 .Fl E ,
1107 .Fl G ,
1108 .Fl H ,
1109 .Fl L ,
1110 .Fl P ,
1111 .Fl T ,
1112 .Fl U ,
1113 .Fl Y ,
1114 .Fl Z ,
1115 the archive formats
1116 .Ar bcpio ,
1117 .Ar sv4cpio ,
1118 .Ar sv4crc ,
1119 .Ar tar ,
1120 and the flawed archive handling during
1121 .Ar list
1122 and
1123 .Ar read
1124 operations are extensions to the
1125 .Tn POSIX
1126 standard.
1127 .Sh SEE ALSO
1128 .Xr cpio 1 ,
1129 .Xr tar 1
1130 .Sh AUTHOR
1131 Keith Muller at the University of California, San Diego.
1132 .Sh ERRORS
1133 .Nm pax
1134 will exit with one of the following values:
1135 .Bl -tag -width 2n
1136 .It 0
1137 All files were processed successfully.
1138 .It 1 
1139 An error occurred.
1140 .El
1141 .Pp
1142 Whenever
1143 .Nm pax
1144 cannot create a file or a link when reading an archive or cannot
1145 find a file when writing an archive, or cannot preserve the user ID,
1146 group ID, or file mode when the
1147 .Fl p
1148 option is specified, a diagnostic message is written to
1149 .Dv standard error
1150 and a non-zero exit status will be returned, but processing will continue.
1151 In the case where
1152 .Nm pax
1153 cannot create a link to a file,
1154 .Nm pax
1155 will not create a second copy of the file.
1156 .Pp
1157 If the extraction of a file from an archive is prematurely terminated by
1158 a signal or error,
1159 .Nm pax
1160 may have only partially extracted a file the user wanted.
1161 Additionally, the file modes of extracted files and directories
1162 may have incorrect file bits, and the modification and access times may be
1163 wrong.
1164 .Pp
1165 If the creation of an archive is prematurely terminated by a signal or error,
1166 .Nm pax
1167 may have only partially created the archive which may violate the specific
1168 archive format specification.
1169 .Pp
1170 If while doing a
1171 .Em copy ,
1172 .Nm pax
1173 detects a file is about to overwrite itself, the file is not copied,
1174 a diagnostic message is written to
1175 .Dv standard error
1176 and when
1177 .Nm pax
1178 completes it will exit with a non-zero exit status.