xref: /freebsd/bin/pax/pax.1 (revision 315ee00f)
1.\"-
2.\" Copyright (c) 1992 Keith Muller.
3.\" Copyright (c) 1992, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Keith Muller of the University of California, San Diego.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\"	@(#)pax.1	8.4 (Berkeley) 4/18/94
34.\"
35.Dd October 19, 2022
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.
397A
398.Ar blocksize
399larger than 32256 bytes violates the
400.Tn POSIX
401standard and will not be portable to all systems.
402A
403.Ar blocksize
404can end with
405.Li k
406or
407.Li b
408to specify multiplication by 1024 (1K) or 512, respectively.
409A pair of
410.Ar blocksizes
411can be separated by
412.Li x
413to indicate a product.
414A specific archive device may impose additional restrictions on the size
415of blocking it will support.
416When blocking is not specified, the default
417.Ar blocksize
418is dependent on the specific archive format being used (see the
419.Fl x
420option).
421.It Fl c
422Match all file or archive members
423.Em except
424those specified by the
425.Ar pattern
426and
427.Ar file
428operands.
429.It Fl d
430Cause files of type directory being copied or archived, or archive members of
431type directory being extracted, to match only the directory file or archive
432member and not the file hierarchy rooted at the directory.
433.It Fl f Ar archive
434Specify
435.Ar archive
436as the pathname of the input or output archive, overriding the default
437.Dv standard input
438(for
439.Em list
440and
441.Em read )
442or
443.Dv standard output
444(for
445.Em write ) .
446A single archive may span multiple files and different archive devices.
447When required,
448.Nm
449will prompt for the pathname of the file or device of the next volume in the
450archive.
451.It Fl i
452Interactively rename files or archive members.
453For each archive member matching a
454.Ar pattern
455operand or each file matching a
456.Ar file
457operand,
458.Nm
459will prompt to
460.Pa /dev/tty
461giving the name of the file, its file mode and its modification time.
462The
463.Nm
464utility will then read a line from
465.Pa /dev/tty .
466If this line is blank, the file or archive member is skipped.
467If this line consists of a single period, the
468file or archive member is processed with no modification to its name.
469Otherwise, its name is replaced with the contents of the line.
470The
471.Nm
472utility will immediately exit with a non-zero exit status if
473.Dv <EOF>
474is encountered when reading a response or if
475.Pa /dev/tty
476cannot be opened for reading and writing.
477.It Fl k
478Do not overwrite existing files.
479.It Fl l
480Link files.
481(The letter ell).
482In the
483.Em copy
484mode
485.Pq Fl r w ,
486hard links are made between the source and destination file hierarchies
487whenever possible.
488.It Fl n
489Select the first archive member that matches each
490.Ar pattern
491operand.
492No more than one archive member is matched for each
493.Ar pattern .
494When members of type directory are matched, the file hierarchy rooted at that
495directory is also matched (unless
496.Fl d
497is also specified).
498.It Fl o Ar options
499Information to modify the algorithm for extracting or writing archive files
500which is specific to the archive format specified by
501.Fl x .
502In general,
503.Ar options
504take the form:
505.Cm name=value
506.It Fl p Ar string
507Specify one or more file characteristic options (privileges).
508The
509.Ar string
510option-argument is a string specifying file characteristics to be retained or
511discarded on extraction.
512The string consists of the specification characters
513.Cm a , e , m , o ,
514and
515.Cm p .
516Multiple characteristics can be concatenated within the same string
517and multiple
518.Fl p
519options can be specified.
520The meaning of the specification characters are as follows:
521.Bl -tag -width 2n
522.It Cm a
523Do not preserve file access times.
524By default, file access times are preserved whenever possible.
525.It Cm e
526.Sq Preserve everything ,
527the user ID, group ID, file mode bits,
528file access time, and file modification time.
529This is intended to be used by
530.Em root ,
531someone with all the appropriate privileges, in order to preserve all
532aspects of the files as they are recorded in the archive.
533The
534.Cm e
535flag is the sum of the
536.Cm o
537and
538.Cm p
539flags.
540.It Cm m
541Do not preserve file modification times.
542By default, file modification times are preserved whenever possible.
543.It Cm o
544Preserve the user ID and group ID.
545.It Cm p
546.Sq Preserve
547the file mode bits.
548This intended to be used by a
549.Em user
550with regular privileges who wants to preserve all aspects of the file other
551than the ownership.
552The file times are preserved by default, but two other flags are offered to
553disable this and use the time of extraction instead.
554.El
555.Pp
556In the preceding list,
557.Sq preserve
558indicates that an attribute stored in the archive is given to the
559extracted file, subject to the permissions of the invoking
560process.
561Otherwise the attribute of the extracted file is determined as
562part of the normal file creation action.
563If neither the
564.Cm e
565nor the
566.Cm o
567specification character is specified, or the user ID and group ID are not
568preserved for any reason,
569.Nm
570will not set the
571.Dv S_ISUID
572.Em ( setuid )
573and
574.Dv S_ISGID
575.Em ( setgid )
576bits of the file mode.
577If the preservation of any of these items fails for any reason,
578.Nm
579will write a diagnostic message to
580.Dv standard error .
581Failure to preserve these items will affect the final exit status,
582but will not cause the extracted file to be deleted.
583If the file characteristic letters in any of the string option-arguments are
584duplicated or conflict with each other, the one(s) given last will take
585precedence.
586For example, if
587.Dl Fl p Ar eme
588is specified, file modification times are still preserved.
589.Pp
590File flags set by
591.Xr chflags 1
592are not understood by
593.Nm ,
594however
595.Xr tar 1
596and
597.Xr dump 8
598will preserve these.
599.It Fl s Ar replstr
600Modify the file or archive member names specified by the
601.Ar pattern
602or
603.Ar file
604operands according to the substitution expression
605.Ar replstr ,
606using the syntax of the
607.Xr ed 1
608utility regular expressions.
609The format of these regular expressions are:
610.Dl /old/new/[gp]
611As in
612.Xr ed 1 ,
613.Cm old
614is a basic regular expression and
615.Cm new
616can contain an ampersand (&), \\n (where n is a digit) back-references,
617or subexpression matching.
618The
619.Cm old
620string may also contain
621.Dv <newline>
622characters.
623Any non-null character can be used as a delimiter (/ is shown here).
624Multiple
625.Fl s
626expressions can be specified.
627The expressions are applied in the order they are specified on the
628command line, terminating with the first successful substitution.
629The optional trailing
630.Cm g
631continues to apply the substitution expression to the pathname substring
632which starts with the first character following the end of the last successful
633substitution.
634The first unsuccessful substitution stops the operation of the
635.Cm g
636option.
637The optional trailing
638.Cm p
639will cause the final result of a successful substitution to be written to
640.Dv standard error
641in the following format:
642.Dl <original pathname> >> <new pathname>
643File or archive member names that substitute to the empty string
644are not selected and will be skipped.
645.It Fl t
646Reset the access times of any file or directory read or accessed by
647.Nm
648to be the same as they were before being read or accessed by
649.Nm .
650.It Fl u
651Ignore files that are older (having a less recent file modification time)
652than a pre-existing file or archive member with the same name.
653During
654.Em read ,
655an archive member with the same name as a file in the file system will be
656extracted if the archive member is newer than the file.
657During
658.Em write ,
659a file system member with the same name as an archive member will be
660written to the archive if it is newer than the archive member.
661During
662.Em copy ,
663the file in the destination hierarchy is replaced by the file in the source
664hierarchy or by a link to the file in the source hierarchy if the file in
665the source hierarchy is newer.
666.It Fl v
667During a
668.Em list
669operation, produce a verbose table of contents using the format of the
670.Xr ls 1
671utility with the
672.Fl l
673option.
674For pathnames representing a hard link to a previous member of the archive,
675the output has the format:
676.Dl <ls -l listing> == <link name>
677For pathnames representing a symbolic link, the output has the format:
678.Dl <ls -l listing> => <link name>
679Where <ls -l listing> is the output format specified by the
680.Xr ls 1
681utility when used with the
682.Fl l
683option.
684Otherwise for all the other operational modes
685.Em ( read , write ,
686and
687.Em copy ) ,
688pathnames are written and flushed to
689.Dv standard error
690without a trailing
691.Dv <newline>
692as soon as processing begins on that file or
693archive member.
694The trailing
695.Dv <newline> ,
696is not buffered, and is written only after the file has been read or written.
697.It Fl x Ar format
698Specify the output archive format, with the default format being
699.Ar ustar .
700The
701.Nm
702utility currently supports the following formats:
703.Bl -tag -width "sv4cpio"
704.It Ar cpio
705The extended cpio interchange format specified in the
706.St -p1003.2
707standard.
708The default blocksize for this format is 5120 bytes.
709Inode and device information about a file (used for detecting file hard links
710by this format) which may be truncated by this format is detected by
711.Nm
712and is repaired.
713.It Ar bcpio
714The old binary cpio format.
715The default blocksize for this format is 5120 bytes.
716This format is not very portable and should not be used when other formats
717are available.
718Inode and device information about a file (used for detecting file hard links
719by this format) which may be truncated by this format is detected by
720.Nm
721and is repaired.
722.It Ar sv4cpio
723The System V release 4 cpio.
724The default blocksize for this format is 5120 bytes.
725Inode and device information about a file (used for detecting file hard links
726by this format) which may be truncated by this format is detected by
727.Nm
728and is repaired.
729.It Ar sv4crc
730The System V release 4 cpio with file crc checksums.
731The default blocksize for this format is 5120 bytes.
732Inode and device information about a file (used for detecting file hard links
733by this format) which may be truncated by this format is detected by
734.Nm
735and is repaired.
736.It Ar tar
737The old
738.Bx
739tar format as found in
740.Bx 4.3 .
741The default blocksize for this format is 10240 bytes.
742Pathnames stored by this format must be 100 characters or less in length.
743Only
744.Em regular
745files,
746.Em hard links , soft links ,
747and
748.Em directories
749will be archived (other file system types are not supported).
750For backwards compatibility with even older tar formats, a
751.Fl o
752option can be used when writing an archive to omit the storage of directories.
753This option takes the form:
754.Dl Fl o Cm write_opt=nodir
755.It Ar ustar
756The extended tar interchange format specified in the
757.St -p1003.2
758standard.
759The default blocksize for this format is 10240 bytes.
760Pathnames stored by this format must be 255 characters or less in length.
761The directory part may be at most 155 characters and each path component
762must be less than 100 characters.
763.El
764.Pp
765The
766.Nm
767utility will detect and report any file that it is unable to store or extract
768as the result of any specific archive format restrictions.
769The individual archive formats may impose additional restrictions on use.
770Typical archive format restrictions include (but are not limited to):
771file pathname length, file size, link pathname length and the type of the file.
772.It Fl z
773Use
774.Xr gzip 1
775to compress (decompress) the archive while writing (reading).
776Incompatible with
777.Fl a .
778.It Fl B Ar bytes
779Limit the number of bytes written to a single archive volume to
780.Ar bytes .
781The
782.Ar bytes
783limit can end with
784.Li m ,
785.Li k ,
786or
787.Li b
788to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
789A pair of
790.Ar bytes
791limits can be separated by
792.Li x
793to indicate a product.
794.Pp
795Note that the specified size is for the uncompressed pax image itself.
796If the
797.Fl z
798option is also used, the resulting file may contain fewer
799.Ar bytes ,
800according to the compressibility of the archive contents.
801See
802.Xr zip 1 Pq Pa ports/archivers/zip
803if compressed volumes of predictable size are required.
804.Pp
805.Em Warning :
806Only use this option when writing an archive to a device which supports
807an end of file read condition based on last (or largest) write offset
808(such as a regular file or a tape drive).
809The use of this option with a floppy or hard disk is not recommended.
810.It Fl D
811This option is the same as the
812.Fl u
813option, except that the file inode change time is checked instead of the
814file modification time.
815The file inode change time can be used to select files whose inode information
816(e.g., uid, gid, etc.) is newer than a copy of the file in the destination
817.Ar directory .
818.It Fl E Ar limit
819Limit the number of consecutive read faults while trying to read a flawed
820archives to
821.Ar limit .
822With a positive
823.Ar limit ,
824.Nm
825will attempt to recover from an archive read error and will
826continue processing starting with the next file stored in the archive.
827A
828.Ar limit
829of 0 will cause
830.Nm
831to stop operation after the first read error is detected on an archive volume.
832A
833.Ar limit
834of
835.Li NONE
836will cause
837.Nm
838to attempt to recover from read errors forever.
839The default
840.Ar limit
841is a small positive number of retries.
842.Pp
843.Em Warning :
844Using this option with
845.Li NONE
846should be used with extreme caution as
847.Nm
848may get stuck in an infinite loop on a very badly flawed archive.
849.It Fl G Ar group
850Select a file based on its
851.Ar group
852name, or when starting with a
853.Cm # ,
854a numeric gid.
855A '\\' can be used to escape the
856.Cm # .
857Multiple
858.Fl G
859options may be supplied and checking stops with the first match.
860.It Fl H
861Follow only command line symbolic links while performing a physical file
862system traversal.
863.It Fl L
864Follow all symbolic links to perform a logical file system traversal.
865.It Fl O
866Force the archive to be one volume.
867If a volume ends prematurely,
868.Nm
869will not prompt for a new volume.
870This option can be useful for
871automated tasks where error recovery cannot be performed by a human.
872.It Fl P
873Do not follow symbolic links, perform a physical file system traversal.
874This is the default mode.
875.It Fl T Ar [from_date][,to_date][/[c][m]]
876Allow files to be selected based on a file modification or inode change
877time falling within a specified time range of
878.Ar from_date
879to
880.Ar to_date
881(the dates are inclusive).
882If only a
883.Ar from_date
884is supplied, all files with a modification or inode change time
885equal to or younger are selected.
886If only a
887.Ar to_date
888is supplied, all files with a modification or inode change time
889equal to or older will be selected.
890When the
891.Ar from_date
892is equal to the
893.Ar to_date ,
894only files with a modification or inode change time of exactly that
895time will be selected.
896.Pp
897When
898.Nm
899is in the
900.Em write
901or
902.Em copy
903mode, the optional trailing field
904.Ar [c][m]
905can be used to determine which file time (inode change, file modification or
906both) are used in the comparison.
907If neither is specified, the default is to use file modification time only.
908The
909.Ar m
910specifies the comparison of file modification time (the time when
911the file was last written).
912The
913.Ar c
914specifies the comparison of inode change time (the time when the file
915inode was last changed; e.g., a change of owner, group, mode, etc).
916When
917.Ar c
918and
919.Ar m
920are both specified, then the modification and inode change times are
921both compared.
922The inode change time comparison is useful in selecting files whose
923attributes were recently changed or selecting files which were recently
924created and had their modification time reset to an older time (as what
925happens when a file is extracted from an archive and the modification time
926is preserved).
927Time comparisons using both file times is useful when
928.Nm
929is used to create a time based incremental archive (only files that were
930changed during a specified time range will be archived).
931.Pp
932A time range is made up of six different fields and each field must contain two
933digits.
934The format is:
935.Pp
936.Dl [[[[[cc]yy]mm]dd]HH]MM[.SS]
937.Pp
938Where
939.Ar cc
940is the first two digits of the year (the century),
941.Ar yy
942is the last two digits of the year,
943the first
944.Ar mm
945is the month (from 01 to 12),
946.Ar dd
947is the day of the month (from 01 to 31),
948.Ar HH
949is the hour of the day (from 00 to 23),
950.Ar MM
951is the minute (from 00 to 59),
952and
953.Ar SS
954is the seconds (from 00 to 59).
955The minute field
956.Ar MM
957is required, while the other fields are optional and must be added in the
958following order:
959.Ar HH , dd , mm , yy , cc .
960The
961.Cm ss
962field may be added independently of the other fields.
963Time ranges are relative to the current time, so
964.Dl Fl T Ar 1234/cm
965would select all files with a modification or inode change time
966of 12:34 PM today or later.
967Multiple
968.Fl T
969time range can be supplied and checking stops with the first match.
970.It Fl U Ar user
971Select a file based on its
972.Ar user
973name, or when starting with a
974.Cm # ,
975a numeric uid.
976A '\\' can be used to escape the
977.Cm # .
978Multiple
979.Fl U
980options may be supplied and checking stops with the first match.
981.It Fl X
982When traversing the file hierarchy specified by a pathname,
983do not descend into directories that have a different device ID.
984See the
985.Li st_dev
986field as described in
987.Xr stat 2
988for more information about device ID's.
989.It Fl Y
990This option is the same as the
991.Fl D
992option, except that the inode change time is checked using the
993pathname created after all the file name modifications have completed.
994.It Fl Z
995This option is the same as the
996.Fl u
997option, except that the modification time is checked using the
998pathname created after all the file name modifications have completed.
999.El
1000.Pp
1001The options that operate on the names of files or archive members
1002.Fl ( c ,
1003.Fl i ,
1004.Fl n ,
1005.Fl s ,
1006.Fl u ,
1007.Fl v ,
1008.Fl D ,
1009.Fl G ,
1010.Fl T ,
1011.Fl U ,
1012.Fl Y ,
1013and
1014.Fl Z )
1015interact as follows.
1016.Pp
1017When extracting files during a
1018.Em read
1019operation, archive members are
1020.Sq selected ,
1021based only on the user specified pattern operands as modified by the
1022.Fl c ,
1023.Fl n ,
1024.Fl u ,
1025.Fl D ,
1026.Fl G ,
1027.Fl T ,
1028.Fl U
1029options.
1030Then any
1031.Fl s
1032and
1033.Fl i
1034options will modify in that order, the names of these selected files.
1035Then the
1036.Fl Y
1037and
1038.Fl Z
1039options will be applied based on the final pathname.
1040Finally the
1041.Fl v
1042option will write the names resulting from these modifications.
1043.Pp
1044When archiving files during a
1045.Em write
1046operation, or copying files during a
1047.Em copy
1048operation, archive members are
1049.Sq selected ,
1050based only on the user specified pathnames as modified by the
1051.Fl n ,
1052.Fl u ,
1053.Fl D ,
1054.Fl G ,
1055.Fl T ,
1056and
1057.Fl U
1058options (the
1059.Fl D
1060option only applies during a copy operation).
1061Then any
1062.Fl s
1063and
1064.Fl i
1065options will modify in that order, the names of these selected files.
1066Then during a
1067.Em copy
1068operation the
1069.Fl Y
1070and the
1071.Fl Z
1072options will be applied based on the final pathname.
1073Finally the
1074.Fl v
1075option will write the names resulting from these modifications.
1076.Pp
1077When one or both of the
1078.Fl u
1079or
1080.Fl D
1081options are specified along with the
1082.Fl n
1083option, a file is not considered selected unless it is newer
1084than the file to which it is compared.
1085.Sh EXIT STATUS
1086The
1087.Nm
1088utility will exit with one of the following values:
1089.Bl -tag -width 2n
1090.It 0
1091All files were processed successfully.
1092.It 1
1093An error occurred.
1094.El
1095.Sh EXAMPLES
1096The command:
1097.Dl "pax -w -f /dev/sa0 ."
1098copies the contents of the current directory to the device
1099.Pa /dev/sa0 .
1100.Pp
1101The command:
1102.Dl pax -v -f filename
1103gives the verbose table of contents for an archive stored in
1104.Pa filename .
1105.Pp
1106The following commands:
1107.Dl mkdir /tmp/to
1108.Dl cd /tmp/from
1109.Dl pax -rw .\ /tmp/to
1110will copy the entire
1111.Pa /tmp/from
1112directory hierarchy to
1113.Pa /tmp/to .
1114.Pp
1115The command:
1116.Dl pax -r -s ',^//*usr//*,,' -f a.pax
1117reads the archive
1118.Pa a.pax ,
1119with all files rooted in ``/usr'' into the archive extracted relative to the
1120current directory.
1121.Pp
1122The command:
1123.Dl pax -rw -i .\ dest_dir
1124can be used to interactively select the files to copy from the current
1125directory to
1126.Pa dest_dir .
1127.Pp
1128The command:
1129.Dl pax -r -pe -U root -G bin -f a.pax
1130will extract all files from the archive
1131.Pa a.pax
1132which are owned by
1133.Em root
1134with group
1135.Em bin
1136and will preserve all file permissions.
1137.Pp
1138The command:
1139.Dl pax -r -w -v -Y -Z home /backup
1140will update (and list) only those files in the destination directory
1141.Pa /backup
1142which are older (less recent inode change or file modification times) than
1143files with the same name found in the source file tree
1144.Pa home .
1145.Sh DIAGNOSTICS
1146Whenever
1147.Nm
1148cannot create a file or a link when reading an archive or cannot
1149find a file when writing an archive, or cannot preserve the user ID,
1150group ID, or file mode when the
1151.Fl p
1152option is specified, a diagnostic message is written to
1153.Dv standard error
1154and a non-zero exit status will be returned, but processing will continue.
1155In the case where pax cannot create a link to a file,
1156.Nm
1157will not create a second copy of the file.
1158.Pp
1159If the extraction of a file from an archive is prematurely terminated by
1160a signal or error,
1161.Nm
1162may have only partially extracted a file the user wanted.
1163Additionally, the file modes of extracted files and directories
1164may have incorrect file bits, and the modification and access times may be
1165wrong.
1166.Pp
1167If the creation of an archive is prematurely terminated by a signal or error,
1168.Nm
1169may have only partially created the archive which may violate the specific
1170archive format specification.
1171.Pp
1172If while doing a
1173.Em copy ,
1174.Nm
1175detects a file is about to overwrite itself, the file is not copied,
1176a diagnostic message is written to
1177.Dv standard error
1178and when
1179.Nm
1180completes it will exit with a non-zero exit status.
1181.Sh SEE ALSO
1182.Xr cpio 1 ,
1183.Xr tar 1
1184.Sh STANDARDS
1185The
1186.Nm
1187utility is a superset of the
1188.St -p1003.2
1189standard.
1190The options
1191.Fl z ,
1192.Fl B ,
1193.Fl D ,
1194.Fl E ,
1195.Fl G ,
1196.Fl H ,
1197.Fl L ,
1198.Fl O ,
1199.Fl P ,
1200.Fl T ,
1201.Fl U ,
1202.Fl Y ,
1203.Fl Z ,
1204the archive formats
1205.Ar bcpio ,
1206.Ar sv4cpio ,
1207.Ar sv4crc ,
1208.Ar tar ,
1209and the flawed archive handling during
1210.Ar list
1211and
1212.Ar read
1213operations are extensions to the
1214.Tn POSIX
1215standard.
1216.Sh HISTORY
1217The
1218.Nm
1219utility appeared in
1220.Bx 4.4 .
1221.Sh AUTHORS
1222.An Keith Muller
1223at the University of California, San Diego
1224.Sh BUGS
1225The
1226.Nm
1227utility does not recognize multibyte characters.
1228.Pp
1229File flags set by
1230.Xr chflags 1
1231are not preserved by
1232.Nm .
1233The BUGS section of
1234.Xr chflags 1
1235has a list of utilities that are unaware of flags.
1236