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