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