1 .\" $OpenBSD: pax.1,v 1.44 2004/02/19 19:15:32 jmc Exp $
2 .\" $NetBSD: pax.1,v 1.3 1995/03/21 09:07:37 cgd Exp $
4 .\" Copyright (c) 1992 Keith Muller.
5 .\" Copyright (c) 1992, 1993
6 .\" The Regents of the University of California. All rights reserved.
8 .\" This code is derived from software contributed to Berkeley by
9 .\" Keith Muller of the University of California, San Diego.
11 .\" Redistribution and use in source and binary forms, with or without
12 .\" modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)pax.1 8.4 (Berkeley) 4/18/94
42 .Nd read and write file archives and copy directory hierarchies
110 .Op Fl b Ar blocksize
151 .Op Fl 0diklntuvDHLPXYZ
181 will read, write, and list the members of an archive file,
182 and will copy directory hierarchies.
184 operation is independent of the specific archive format,
185 and supports a wide variety of different archive formats.
186 A list of supported archive formats can be found under the description of the
194 options specifies which of the following functional modes
197 .Em list , read , write ,
204 will write to standard output
205 a table of contents of the members of the archive file read from
206 standard input, whose pathnames match the specified
208 The table of contents contains one filename per line
209 and is written using single line buffering.
214 extracts the members of the archive file read from the standard input,
215 with pathnames matching the specified
217 The archive format and blocking is automatically determined on input.
218 When an extracted file is a directory, the entire file hierarchy
219 rooted at that directory is extracted.
220 All extracted files are created relative to the current file hierarchy.
221 The setting of ownership, access and modification times, and file mode of
222 the extracted files are discussed in more detail under the
229 writes an archive containing the
231 operands to standard output
232 using the specified archive format.
235 operands are specified, a list of files to copy with one per line is read from
239 operand is also a directory, the entire file hierarchy rooted
240 at that directory will be included.
247 operands to the destination
251 operands are specified, a list of files to copy with one per line is read from
255 operand is also a directory the entire file
256 hierarchy rooted at that directory will be included.
259 is as if the copied files were written to an archive file and then
260 subsequently extracted, except that there may be hard links between
261 the original and the copied files (see the
268 must not be one of the
270 operands or a member of a file hierarchy rooted at one of the
275 under these conditions is unpredictable.
278 While processing a damaged archive during a
284 will attempt to recover from media defects and will search through the archive
285 to locate and process the largest number of archive members possible (see the
287 option for more details on error handling).
291 operand specifies a destination directory pathname.
294 operand does not exist, or it is not writable by the user,
295 or it is not of type directory,
297 will exit with a non-zero exit status.
301 operand is used to select one or more pathnames of archive members.
302 Archive members are selected using the pattern matching notation described
307 operand is not supplied, all members of the archive will be selected.
310 matches a directory, the entire file hierarchy rooted at that directory will
314 operand does not select at least one archive member,
318 operands in a diagnostic message to standard error
319 and then exit with a non-zero exit status.
323 operand specifies the pathname of a file to be copied or archived.
326 operand does not select at least one archive member,
330 operand pathnames in a diagnostic message to standard error
331 and then exit with a non-zero exit status.
333 The options are as follows:
339 character as a pathname terminator, instead of newline
341 This applies only to the pathnames read from standard input in
342 the write and copy modes,
343 and to the pathnames written to standard output in list mode.
344 This option is expected to be used in concert with the
356 to the end of an archive that was previously written.
357 If an archive format is not specified with a
359 option, the format currently being used in the archive will be selected.
360 Any attempt to append to an archive in a format different from the
361 format already used in the archive will cause
364 with a non-zero exit status.
365 The blocking size used in the archive volume where writing starts
366 will continue to be used for the remainder of that archive volume.
369 Many storage devices are not able to support the operations necessary
370 to perform an append operation.
371 Any attempt to append to an archive stored on such a device may damage the
372 archive or have other unpredictable results.
373 Tape drives in particular are more likely to not support an append operation.
374 An archive stored in a regular file system file or on a disk device will
375 usually support an append operation.
378 Limit the number of bytes written to a single archive volume to
387 to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
390 limits can be separated by
392 to indicate a product.
395 Only use this option when writing an archive to a device which supports
396 an end of file read condition based on last (or largest) write offset
397 (such as a regular file or a tape drive).
398 The use of this option with a floppy or hard disk is not recommended.
400 .It Fl b Ar blocksize
404 block the output at a positive decimal integer number of
405 bytes per write to the archive file.
408 must be a multiple of 512 bytes with a maximum of 64512 bytes.
409 Archives larger than 32256 bytes violate the
411 standard and will not be portable to all systems.
418 to specify multiplication by 1024 (1K) or 512, respectively.
423 to indicate a product.
424 A specific archive device may impose additional restrictions on the size
425 of blocking it will support.
426 When blocking is not specified, the default
428 is dependent on the specific archive format being used (see the
433 Match all file or archive members
435 those specified by the
442 This option is the same as the
444 option, except that the file inode change time is checked instead of the
445 file modification time.
446 The file inode change time can be used to select files whose inode information
447 (e.g., UID, GID, etc.) is newer than a copy of the file in the destination
451 Cause files of type directory being copied or archived, or archive members of
452 type directory being extracted, to match only the directory file or archive
453 member and not the file hierarchy rooted at the directory.
456 Limit the number of consecutive read faults while trying to read a flawed
462 will attempt to recover from an archive read error and will
463 continue processing starting with the next file stored in the archive.
468 to stop operation after the first read error is detected on an archive volume.
475 to attempt to recover from read errors forever.
478 is a small positive number of retries.
481 Using this option with
483 should be used with extreme caution as
485 may get stuck in an infinite loop on a very badly flawed archive.
490 as the pathname of the input or output archive, overriding the default
498 A single archive may span multiple files and different archive devices.
501 will prompt for the pathname of the file or device of the next volume in the
505 Select a file based on its
507 name, or when starting with a
512 can be used to escape the
516 options may be supplied and checking stops with the first match.
519 Follow only command-line symbolic links while performing a physical file
523 Interactively rename files or archive members.
524 For each archive member matching a
526 operand or each file matching a
532 giving the name of the file, its file mode, and its modification time.
534 will then read a line from
536 If this line is blank, the file or archive member is skipped.
537 If this line consists of a single period, the
538 file or archive member is processed with no modification to its name.
539 Otherwise, its name is replaced with the contents of the line.
541 will immediately exit with a non-zero exit status if
543 is encountered when reading a response or if
545 cannot be opened for reading and writing.
548 Do not overwrite existing files.
551 Follow all symbolic links to perform a logical file system traversal.
554 (The lowercase letter
561 hard links are made between the source and destination file hierarchies
565 Select the first archive member that matches each
568 No more than one archive member is matched for each
570 When members of type directory are matched, the file hierarchy rooted at that
571 directory is also matched (unless
576 Force the archive to be one volume.
577 If a volume ends prematurely,
579 will not prompt for a new volume.
580 This option can be useful for
581 automated tasks where error recovery cannot be performed by a human.
584 Information to modify the algorithm for extracting or writing archive files
585 which is specific to the archive format specified by
590 .Ar name Ns = Ns Ar value .
592 If the "-x pax" option is used,
593 the ":=" form of keyword specification is supported.
594 Also, the following new keywords are implemented:
601 globexhdr.name=<string>
603 invalid=<action> for actions
604 bypass, rename, utf-8 (recognized, but ignored), and write
609 for the 'F' conversion specifier
610 (not the 'D', 'T', 'M', or 'L' specifiers)
614 all keywords in pax Extended Header,
615 with the following restrictions:
618 keyword recognized, but ignored
620 keyword not recognized
622 keyword not recognized
626 In "copy mode", only the following new keywords are supported:
633 path= (from pax Extended Header description)
637 Do not follow symbolic links, perform a physical file system traversal.
638 This is the default mode.
641 Specify one or more file characteristic options (privileges).
644 option-argument is a string specifying file characteristics to be retained or
645 discarded on extraction.
646 The string consists of the specification characters
650 Multiple characteristics can be concatenated within the same string
653 options can be specified.
654 The meanings of the specification characters are as follows:
657 Do not preserve file access times.
658 By default, file access times are preserved whenever possible.
660 .Sq Preserve everything ,
661 the user ID, group ID, file mode bits,
662 file access time, and file modification time.
663 This is intended to be used by
665 someone with all the appropriate privileges, in order to preserve all
666 aspects of the files as they are recorded in the archive.
669 flag is the sum of the
675 Do not preserve file modification times.
676 By default, file modification times are preserved whenever possible.
678 Preserve the user ID and group ID.
682 This is intended to be used by a
684 with regular privileges who wants to preserve all aspects of the file other
686 The file times are preserved by default, but two other flags are offered to
687 disable this and use the time of extraction instead.
690 In the preceding list,
692 indicates that an attribute stored in the archive is given to the
693 extracted file, subject to the permissions of the invoking
695 Otherwise the attribute of the extracted file is determined as
696 part of the normal file creation action.
701 specification character is specified, or the user ID and group ID are not
702 preserved for any reason,
710 bits of the file mode.
711 If the preservation of any of these items fails for any reason,
713 will write a diagnostic message to standard error.
714 Failure to preserve these items will affect the final exit status,
715 but will not cause the extracted file to be deleted.
716 If the file characteristic letters in any of the string option-arguments are
717 duplicated or conflict with each other, the one(s) given last will take
721 is specified, file modification times are still preserved.
723 Read an archive file from standard input
724 and extract the specified
726 If any intermediate directories are needed in order to extract an archive
727 member, these directories will be created as if
729 was called with the bitwise inclusive
732 .Dv S_IRWXU , S_IRWXG ,
735 as the mode argument.
736 When the selected archive format supports the specification of linked
737 files and these files cannot be linked while the archive is being extracted,
739 will write a diagnostic message to standard error
740 and exit with a non-zero exit status at the completion of operation.
742 Modify the file or archive member names specified by the
746 operands according to the substitution expression
748 using the syntax of the
750 utility regular expressions.
751 The format of these regular expressions is:
756 is a basic regular expression and
758 can contain an ampersand
763 is a digit) back-references,
764 or subexpression matching.
767 string may also contain newline characters.
768 Any non-null character can be used as a delimiter
775 expressions can be specified.
776 The expressions are applied in the order they are specified on the
777 command line, terminating with the first successful substitution.
778 The optional trailing
780 continues to apply the substitution expression to the pathname substring,
781 which starts with the first character following the end of the last successful
783 The first unsuccessful substitution stops the operation of the
786 The optional trailing
788 will cause the final result of a successful substitution to be written to
789 standard error in the following format:
790 .Dl <original pathname> >> <new pathname>
791 File or archive member names that substitute to the empty string
792 are not selected and will be skipped.
793 .It Fl T Ar [from_date][,to_date][/[c][m]]
794 Allow files to be selected based on a file modification or inode change
795 time falling within a specified time range of
799 (the dates are inclusive).
802 is supplied, all files with a modification or inode change time
803 equal to or younger are selected.
806 is supplied, all files with a modification or inode change time
807 equal to or older will be selected.
812 only files with a modification or inode change time of exactly that
813 time will be selected.
821 mode, the optional trailing field
823 can be used to determine which file time (inode change, file modification or
824 both) are used in the comparison.
825 If neither is specified, the default is to use file modification time only.
828 specifies the comparison of file modification time (the time when
829 the file was last written).
832 specifies the comparison of inode change time (the time when the file
833 inode was last changed; e.g., a change of owner, group, mode, etc).
838 are both specified, then the modification and inode change times are
840 The inode change time comparison is useful in selecting files whose
841 attributes were recently changed or selecting files which were recently
842 created and had their modification time reset to an older time (as what
843 happens when a file is extracted from an archive and the modification time
845 Time comparisons using both file times is useful when
847 is used to create a time based incremental archive (only files that were
848 changed during a specified time range will be archived).
850 A time range is made up of six different fields and each field must contain two
853 .Dl [[[[[cc]yy]mm]dd]HH]MM[.SS]
856 is the first two digits of the year (the century),
858 is the last two digits of the year,
861 is the month (from 01 to 12),
863 is the day of the month (from 01 to 31),
865 is the hour of the day (from 00 to 23),
867 is the minute (from 00 to 59),
870 is the seconds (from 00 to 59).
873 is required, while the other fields are optional and must be added in the
876 .Cm \& HH , dd , mm ,
881 field may be added independently of the other fields.
882 Time ranges are relative to the current time, so
884 would select all files with a modification or inode change time
885 of 12:34 PM today or later.
888 time range can be supplied and checking stops with the first match.
891 Reset the access times of any file or directory read or accessed by
893 to be the same as they were before being read or accessed by
897 Select a file based on its
899 name, or when starting with a
904 can be used to escape the
908 options may be supplied and checking stops with the first match.
911 Ignore files that are older (having a less recent file modification time)
912 than a pre-existing file or archive member with the same name.
915 an archive member with the same name as a file in the file system will be
916 extracted if the archive member is newer than the file.
919 a file system member with the same name as an archive member will be
920 written to the archive if it is newer than the archive member.
923 the file in the destination hierarchy is replaced by the file in the source
924 hierarchy or by a link to the file in the source hierarchy if the file in
925 the source hierarchy is newer.
930 operation, produce a verbose table of contents using the format of the
935 For pathnames representing a hard link to a previous member of the archive,
936 the output has the format:
937 .Dl <ls -l listing> == <link name>
938 For pathnames representing a symbolic link, the output has the format:
939 .Dl <ls -l listing> => <link name>
940 Where <ls -l listing> is the output format specified by the
942 utility when used with the
945 Otherwise for all the other operational modes
946 .Po Em read , write , Li and Em copy
948 pathnames are written and flushed to standard error
949 without a trailing newline
950 as soon as processing begins on that file or
953 is not buffered and is written only after the file has been read or written.
956 Write files to the standard output
957 in the specified archive format.
960 operands are specified, standard input
961 is read for a list of pathnames with one per line without any leading or
966 When traversing the file hierarchy specified by a pathname,
967 do not descend into directories that have a different device ID.
970 field as described in
972 for more information about device IDs.
975 Specify the output archive format, with the default format being
978 currently supports the following formats:
979 .Bl -tag -width "sv4cpio"
982 The old binary cpio format.
983 The default blocksize for this format is 5120 bytes.
984 This format is not very portable and should not be used when other formats
986 Inode and device information about a file (used for detecting file hard links
987 by this format), which may be truncated by this format, is detected by
992 The extended cpio interchange format specified in the
995 The default blocksize for this format is 5120 bytes.
996 Inode and device information about a file (used for detecting file hard links
997 by this format), which may be truncated by this format, is detected by
1002 "pax interchange format", described in the
1003 EXTENDED DESCRIPTION of the pax interchange format
1004 in The Open Group's SUSv3 specification.
1005 Includes support for pax Header Block,
1006 pax Extended Header,
1007 pax Extended Header Keyword Precedence, and
1008 pax Extended Header File Times.
1011 The System V release 4 cpio.
1012 The default blocksize for this format is 5120 bytes.
1013 Inode and device information about a file (used for detecting file hard links
1014 by this format), which may be truncated by this format, is detected by
1019 The System V release 4 cpio with file crc checksums.
1020 The default blocksize for this format is 5120 bytes.
1021 Inode and device information about a file (used for detecting file hard links
1022 by this format), which may be truncated by this format, is detected by
1027 The old BSD tar format as found in BSD4.3.
1028 The default blocksize for this format is 10240 bytes.
1029 Pathnames stored by this format must be 100 characters or less in length.
1033 .Em hard links , soft links ,
1036 will be archived (other file system types are not supported).
1037 For backwards compatibility with even older tar formats, a
1039 option can be used when writing an archive to omit the storage of directories.
1040 This option takes the form:
1041 .Dl Fl o Cm write_opt=nodir
1044 The extended tar interchange format specified in the
1047 The default blocksize for this format is 10240 bytes.
1048 Filenames stored by this format must be 100 characters or less in length;
1049 the total pathname must be 255 characters or less.
1053 will detect and report any file that it is unable to store or extract
1054 as the result of any specific archive format restrictions.
1055 The individual archive formats may impose additional restrictions on use.
1056 Typical archive format restrictions include (but are not limited to):
1057 file pathname length, file size, link pathname length, and the type of the
1061 This option is the same as the
1063 option, except that the inode change time is checked using the
1064 pathname created after all the file name modifications have completed.
1067 This option is the same as the
1069 option, except that the modification time is checked using the
1070 pathname created after all the file name modifications have completed.
1075 to compress (decompress) the archive while writing (reading).
1080 The options that operate on the names of files or archive members
1095 interact as follows.
1097 When extracting files during a
1099 operation, archive members are
1101 based only on the user specified pattern operands as modified by the
1114 options will modify in that order, the names of these selected files.
1119 options will be applied based on the final pathname.
1122 option will write the names resulting from these modifications.
1124 When archiving files during a
1126 operation, or copying files during a
1128 operation, archive members are
1130 based only on the user specified pathnames as modified by the
1140 option only applies during a copy operation).
1145 options will modify in that order, the names of these selected files.
1152 options will be applied based on the final pathname.
1155 option will write the names resulting from these modifications.
1157 When one or both of the
1161 options are specified along with the
1163 option, a file is not considered selected unless it is newer
1164 than the file to which it is compared.
1168 Path in which to store temporary files.
1171 .Li $ pax -w -f /dev/rst0 \&.
1173 Copies the contents of the current directory to the device
1176 .Li $ pax -v -f filename
1178 Gives the verbose table of contents for an archive stored in
1181 .Li $ mkdir newdir ;
1183 .Li pax -rw \&. newdir
1185 This sequence of commands will copy the entire
1187 directory hierarchy to
1190 .Li $ pax -r -s ',^//*usr//*,,' -f a.pax
1194 with all files rooted in
1196 into the archive extracted relative to the current directory.
1198 .Li $ pax -rw -i \&. dest_dir
1200 Can be used to interactively select the files to copy from the current
1204 .Li "$ pax -r -pe -U root -G bin -f a.pax"
1206 Extract all files from the archive
1212 and preserve all file permissions.
1214 .Li "$ pax -r -w -v -Y -Z home /backup"
1216 Update (and list) only those files in the destination directory
1218 which are older (less recent inode change or file modification times) than
1219 files with the same name found in the source file tree
1223 will exit with one of the following values:
1226 All files were processed successfully.
1233 cannot create a file or a link when reading an archive or cannot
1234 find a file when writing an archive, or cannot preserve the user ID,
1235 group ID, or file mode when the
1237 option is specified, a diagnostic message is written to standard error
1238 and a non-zero exit status will be returned, but processing will continue.
1241 cannot create a link to a file,
1243 will not create a second copy of the file.
1245 If the extraction of a file from an archive is prematurely terminated by
1248 may have only partially extracted a file the user wanted.
1249 Additionally, the file modes of extracted files and directories
1250 may have incorrect file bits, and the modification and access times may be
1253 If the creation of an archive is prematurely terminated by a signal or error,
1255 may have only partially created the archive, which may violate the specific
1256 archive format specification.
1261 detects a file is about to overwrite itself, the file is not copied,
1262 a diagnostic message is written to standard error
1265 completes it will exit with a non-zero exit status.
1270 "Archiving with Pax", Dru Lavigne, ONLamp.com BSD DevCenter,
1271 http://www.onlamp.com/pub/a/bsd/2002/08/22/FreeBSD_Basics.html
1274 http://heirloom.sourceforge.net/man/pax.1.html
1278 utility is a superset of the
1299 and the flawed archive handling during
1303 operations are extensions to the
1307 Keith Muller at the University of California, San Diego.