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