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