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