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