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