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