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