Debian Codegraph @

pax.1

raw
1 .\" $MirOS: src/bin/pax/pax.1,v 1.39 2024/01/05 02:08:48 tg Exp $
2 .\" $OpenBSD: pax.1,v 1.74 2018/07/23 19:02:49 kn Exp $
3 .\" $NetBSD: pax.1,v 1.3 1995/03/21 09:07:37 cgd Exp $
4 .\"
5 .\" Copyright © 2005, 2009, 2011, 2012, 2014, 2016, 2017, 2018, 2021
6 .\" mirabilos <[email protected]>
7 .\" Copyright (c) 1992 Keith Muller.
8 .\" Copyright (c) 1992, 1993
9 .\" The Regents of the University of California. All rights reserved.
10 .\"
11 .\" This code is derived from software contributed to Berkeley by
12 .\" Keith Muller of the University of California, San Diego.
13 .\"
14 .\" Redistribution and use in source and binary forms, with or without
15 .\" modification, are permitted provided that the following conditions
16 .\" are met:
17 .\" 1. Redistributions of source code must retain the above copyright
18 .\" notice, this list of conditions and the following disclaimer.
19 .\" 2. Redistributions in binary form must reproduce the above copyright
20 .\" notice, this list of conditions and the following disclaimer in the
21 .\" documentation and/or other materials provided with the distribution.
22 .\" 3. Neither the name of the University nor the names of its contributors
23 .\" may be used to endorse or promote products derived from this software
24 .\" without specific prior written permission.
25 .\"
26 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 .\" SUCH DAMAGE.
37 .\"
38 .\" @(#)pax.1 8.4 (Berkeley) 4/18/94
39 .\"
40 .\"-
41 .\" $miros: contrib/samples/portmdoc,v 1.23 2024/01/04 22:52:50 tg Exp $
42 .\"-
43 .\" Copyright © 2008, 2009, 2010, 2016, 2018, 2020, 2023
44 .\" mirabilos <[email protected]>
45 .\"
46 .\" Glue GNU groff (BSD and GNU mdoc both) to AT&T nroff (UCB mdoc).
47 .\" * ` generates ‘ in gnroff, so use \`
48 .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
49 .\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
50 .\" thus use - for hyphens and \- for minus signs and option dashes
51 .\" * ~ is size-reduced and placed atop in groff, so use \*(TI
52 .\" * ^ is size-reduced and placed atop in groff, so use \*(ha
53 .\" * \(en does not work in nroff, so use \*(en for a solo en dash
54 .\" * and \*(EM for a correctly spaced em dash
55 .\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba
56 .\" Also make sure to use \& *before* a punctuation char that is to not
57 .\" be interpreted as punctuation, and especially with two-letter words
58 .\" but also (after) a period that does not end a sentence (“e.g.\&”).
59 .\"-
60 .\"
61 .\" Implement .Dd with the Mdocdate RCS keyword
62 .\"
63 .rn Dd xD
64 .de Dd
65 .ie \\$1$Mdocdate: \{\
66 . xD \\$2 \\$3, \\$4
67 .\}
68 .el .xD \\$1 \\$2 \\$3
69 ..
70 .\"
71 .\" .Dd must come before most everything, because when called
72 .\" with -mandoc it loads -mdoc via .so in .Dd (first macro).
73 .\"
74 .Dd $Mdocdate: January 5 2024 $
75 .\"
76 .\" Check which macro package we use, and do other -mdoc setup.
77 .\"
78 .ie \n(.g \{\
79 . if n .ss \n[.ss] 0
80 . if \*[.T]ascii .tr \-\N'45'
81 . if \*[.T]latin1 .tr \-\N'45'
82 . if \*[.T]utf8 .tr \-\N'45'
83 . if \*[.T]utf8 .tr \(la\*(Lt
84 . if \*[.T]utf8 .tr \(ra\*(Gt
85 . ds <= \(<=
86 . ds >= \(>=
87 . ds Rq \(rq
88 . ds Lq \(lq
89 . ds sL \(aq
90 . ds sR \(aq
91 . if \*[.T]utf8 .ds sL `
92 . if \*[.T]ps .ds sL `
93 . if \*[.T]utf8 .ds sR '
94 . if \*[.T]ps .ds sR '
95 . ds aq \(aq
96 . ds TI \(ti
97 . ds ha \(ha
98 . ds en \(en
99 . ie d volume-ds-1 .ds tT gnu
100 . el .ie d doc-volume-ds-1 .ds tT gnp
101 . el .ds tT bsd
102 .\}
103 .el \{\
104 . ds aq '
105 . ds TI ~
106 . ds ha ^
107 . ds en \(em
108 . ds tT ucb
109 .\}
110 .ie n \{\
111 . ds EM \ \(em\ \&
112 .\}
113 .el \{\
114 . ds EM \f(TR\|\(em\|\fP
115 .\}
116 .\"
117 .\" Add UCB mdoc compatibility to GNU mdoc
118 .\" Implement .Mx (MirBSD)
119 .\"
120 .ie "\*(tT"gnu" \{\
121 . ds sP \s0
122 . ds tN \*[Tn-font-size]
123 . eo
124 . de Mx
125 . nr curr-font \n[.f]
126 . nr curr-size \n[.ps]
127 . ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
128 . ds str-Mx1 \*(tN\%MirBSD\*[str-Mx]
129 . if !\n[arg-limit] \
130 . if \n[.$] \{\
131 . ds macro-name Mx
132 . parse-args \$@
133 . \}
134 . if (\n[arg-limit] > \n[arg-ptr]) \{\
135 . nr arg-ptr +1
136 . ie (\n[type\n[arg-ptr]] == 2) \
137 . ds str-Mx1 \*(tN\%MirBSD\~#\*[arg\n[arg-ptr]]\*[str-Mx]
138 . el \
139 . nr arg-ptr -1
140 . \}
141 . ds arg\n[arg-ptr] "\*[str-Mx1]
142 . nr type\n[arg-ptr] 2
143 . ds space\n[arg-ptr] "\*[space]
144 . nr num-args (\n[arg-limit] - \n[arg-ptr])
145 . nr arg-limit \n[arg-ptr]
146 . if \n[num-args] \
147 . parse-space-vector
148 . print-recursive
149 ..
150 . de Aq
151 . if !\n[arg-limit] \
152 . ds macro-name Aq
153 . ie \n[in-authors-section] \{\
154 . ds quote-left \*(Lt
155 . ds quote-right \*(Gt
156 . \}
157 . el \{\
158 . ds quote-left \[la]
159 . ds quote-right \[ra]
160 . \}
161 . enclose-string \$@
162 ..
163 . ec
164 .\}
165 .el .ie "\*(tT"gnp" \{\
166 . ds sP \s0
167 . ie t .ds tN \s[(\n[.ps]u-1z)]
168 . el .ds tN
169 . eo
170 . de Mx
171 . nr doc-curr-font \n[.f]
172 . nr doc-curr-size \n[.ps]
173 . ds doc-str-Mx \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]
174 . ds doc-str-Mx1 \*(tN\%MirBSD\*[doc-str-Mx]
175 . if !\n[doc-arg-limit] \
176 . if \n[.$] \{\
177 . ds doc-macro-name Mx
178 . doc-parse-args \$@
179 . \}
180 . if (\n[doc-arg-limit] > \n[doc-arg-ptr]) \{\
181 . nr doc-arg-ptr +1
182 . ie (\n[doc-type\n[doc-arg-ptr]] == 2) \
183 . ds doc-str-Mx1 \*(tN\%MirBSD\~#\*[doc-arg\n[doc-arg-ptr]]\*[doc-str-Mx]
184 . el \
185 . nr doc-arg-ptr -1
186 . \}
187 . ds doc-arg\n[doc-arg-ptr] "\*[doc-str-Mx1]
188 . nr doc-type\n[doc-arg-ptr] 2
189 . ds doc-space\n[doc-arg-ptr] "\*[doc-space]
190 . nr doc-num-args (\n[doc-arg-limit] - \n[doc-arg-ptr])
191 . nr doc-arg-limit \n[doc-arg-ptr]
192 . if \n[doc-num-args] \
193 . doc-parse-space-vector
194 . doc-print-recursive
195 ..
196 . ec
197 .\}
198 .el \{\
199 . de Mx
200 . nr cF \\n(.f
201 . nr cZ \\n(.s
202 . ds aa \&\f\\n(cF\s\\n(cZ
203 . if \\n(aC==0 \{\
204 . ie \\n(.$==0 \&\\*(tNMirBSD\\*(aa
205 . el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
206 . \}
207 . if \\n(aC>\\n(aP \{\
208 . nr aP \\n(aP+1
209 . ie \\n(C\\n(aP==2 \{\
210 . nr xX 0
211 . nr xX 1+\\*(A\\n(aP
212 . as b1 \&\\*(tNMirBSD\ \&
213 . if \\n(xX>0 .as b1 #\&
214 . as b1 \&\\*(A\\n(aP\\*(aa
215 . rr xX
216 . ie \\n(aC>\\n(aP \{\
217 . nr aP \\n(aP+1
218 . nR
219 . \}
220 . el .aZ
221 . \}
222 . el \{\
223 . as b1 \&\\*(tNMirBSD\\*(aa
224 . nR
225 . \}
226 . \}
227 ..
228 .\}
229 .\" </MirCVS://contrib/samples/portmdoc>
230 .\"-
231 .ie \ng==1 \{\
232 . ds nc mircpio
233 . ds np mirpax
234 . ds nt mirtar
235 . ds nm mirpax
236 . Dt MIRPAX 1
237 .\}
238 .el .ie \ng==2 \{\
239 . ds nc paxcpio
240 . ds np pax
241 . ds nt paxtar
242 . ds nm pax
243 . Dt PAX 1
244 .\}
245 .el \{\
246 . ds nc cpio
247 . ds np pax
248 . ds nt tar
249 . ds nm pax
250 . Dt PAX 1
251 .\}
252 .\"-
253 .Os MirBSD
254 .Sh NAME
255 .ie \ng==1 \{\
256 .Nm mirpax
257 .Nd read and write file archives and copy directory hierarchies
258 .\}
259 .el \{\
260 .Nm pax
261 .Nd read and write file archives and copy directory hierarchies
262 .\}
263 .Sh SYNOPSIS
264 .Bk -words
265 .Nm \*(nm
266 .Op Fl 0cdJjnOvz
267 .Op Fl E Ar limit
268 .Op Fl f Ar archive
269 .Op Fl G Ar group
270 .Op Fl s Ar replstr
271 .Op Fl T Ar range
272 .Op Fl U Ar user
273 .Op Ar pattern ...
274 .Nm \*(nm
275 .Fl r
276 .Op Fl 0cDdiJjknOuvYZz
277 .Op Fl E Ar limit
278 .Op Fl f Ar archive
279 .Op Fl G Ar group
280 .Op Fl M Ar flag
281 .Op Fl o Ar options
282 .Op Fl p Ar string
283 .Op Fl s Ar replstr
284 .Op Fl T Ar range
285 .Op Fl U Ar user
286 .Op Ar pattern ...
287 .Nm \*(nm
288 .Fl w
289 .Op Fl 0adHiJjLOPtuvXz
290 .Op Fl B Ar bytes
291 .Op Fl b Ar blocksize
292 .Op Fl f Ar archive
293 .Op Fl G Ar group
294 .Op Fl M Ar flag
295 .Op Fl o Ar options
296 .Op Fl s Ar replstr
297 .Op Fl T Ar range
298 .Op Fl U Ar user
299 .Op Fl x Ar format
300 .Op Ar
301 .Nm \*(nm
302 .Fl rw
303 .Op Fl 0DdHiJjkLlnOPtuvXYZ
304 .Op Fl G Ar group
305 .Op Fl p Ar string
306 .Op Fl s Ar replstr
307 .Op Fl T Ar range
308 .Op Fl U Ar user
309 .Op Ar
310 .Ar directory
311 .Ek
312 .Sh DESCRIPTION
313 .Nm
314 will read, write, and list the members of an archive file
315 and will copy directory hierarchies.
316 .Nm
317 operation is independent of the specific archive format
318 and supports a wide variety of different archive formats.
319 A list of supported archive formats can be found under the description of the
320 .Fl x
321 option.
322 .Pp
323 The presence of the
324 .Fl r
325 and the
326 .Fl w
327 options specifies which of the following functional modes
328 .Nm
329 will operate under:
330 .Em list , read , write ,
331 and
332 .Em copy .
333 .Bl -tag -width 6n
334 .It Aq none
335 .Em List .
336 .Nm
337 will write to standard output
338 a table of contents of the members of the archive file read from
339 standard input, whose pathnames match the specified
340 .Ar pattern
341 arguments.
342 The table of contents contains one filename per line
343 and is written using single line buffering.
344 .It Fl r
345 .Em Read .
346 .Nm
347 extracts the members of the archive file read from the standard input,
348 with pathnames matching the specified
349 .Ar pattern
350 arguments.
351 The archive format and blocking is automatically determined on input.
352 When an extracted file is a directory, the entire file hierarchy
353 rooted at that directory is extracted.
354 All extracted files are created relative to the current file hierarchy.
355 The setting of ownership, access and modification times, and file mode of
356 the extracted files are discussed in more detail under the
357 .Fl p
358 option.
359 .It Fl w
360 .Em Write .
361 .Nm
362 writes an archive containing the
363 .Ar file
364 operands to standard output
365 using the specified archive format.
366 When no
367 .Ar file
368 operands are specified, a list of files to copy with one per line is read from
369 standard input.
370 When a
371 .Ar file
372 operand is also a directory, the entire file hierarchy rooted
373 at that directory will be included.
374 .It Fl rw
375 .Em Copy .
376 .Nm
377 copies the
378 .Ar file
379 operands to the destination
380 .Ar directory .
381 When no
382 .Ar file
383 operands are specified, a list of files to copy with one per line is read from
384 the standard input.
385 When a
386 .Ar file
387 operand is also a directory the entire file
388 hierarchy rooted at that directory will be included.
389 The effect of the
390 .Em copy
391 is as if the copied files were written to an archive file and then
392 subsequently extracted, except that there may be hard links between
393 the original and the copied files (see the
394 .Fl l
395 option below).
396 .Pp
397 .Sy Warning :
398 The destination
399 .Ar directory
400 must not be one of the
401 .Ar file
402 operands or a member of a file hierarchy rooted at one of the
403 .Ar file
404 operands.
405 The result of a
406 .Em copy
407 under these conditions is unpredictable.
408 .El
409 .Pp
410 While processing a damaged archive during a read or list operation,
411 .Nm
412 will attempt to recover from media defects and will search through the archive
413 to locate and process the largest number of archive members possible (see the
414 .Fl E
415 option for more details on error handling).
416 .Pp
417 The
418 .Ar directory
419 operand specifies a destination directory pathname.
420 If the
421 .Ar directory
422 operand does not exist, or it is not writable by the user,
423 or it is not of type directory,
424 .Nm
425 will exit with a non-zero exit status.
426 .Pp
427 The
428 .Ar pattern
429 operand is used to select one or more pathnames of archive members.
430 Archive members are selected using the pattern matching notation described
431 by
432 .Xr glob 7 .
433 When the
434 .Ar pattern
435 operand is not supplied, all members of the archive will be selected.
436 When a
437 .Ar pattern
438 matches a directory, the entire file hierarchy rooted at that directory will
439 be selected.
440 When a
441 .Ar pattern
442 operand does not select at least one archive member,
443 .Nm
444 will write these
445 .Ar pattern
446 operands in a diagnostic message to standard error
447 and then exit with a non-zero exit status.
448 .Pp
449 The
450 .Ar file
451 operand specifies the pathname of a file to be copied or archived.
452 When a
453 .Ar file
454 operand does not select at least one archive member,
455 .Nm
456 will write these
457 .Ar file
458 operand pathnames in a diagnostic message to standard error
459 and then exit with a non-zero exit status.
460 .Pp
461 The options are as follows:
462 .Bl -tag -width Ds
463 .It Fl 0
464 Use the NUL
465 .Pq Ql \e0
466 character as a pathname terminator, instead of newline
467 .Pq Ql \en .
468 This applies only to the pathnames read from standard input in
469 the write and copy modes,
470 and to the pathnames written to standard output in list mode.
471 This option is expected to be used in concert with the
472 .Fl print0
473 function in
474 .Xr find 1 ,
475 the
476 .Fl d Ar \*(aq\*(aq
477 option to the
478 .Ic read
479 built-in utility of
480 .Xr mksh 1
481 or the
482 .Fl 0
483 flag in
484 .Xr xargs 1 .
485 .It Fl a
486 Append the given
487 .Ar file
488 operands
489 to the end of an archive that was previously written.
490 If an archive format is not specified with a
491 .Fl x
492 option, the format currently being used in the archive will be selected.
493 Any attempt to append to an archive in a format different from the
494 format already used in the archive will cause
495 .Nm
496 to exit immediately
497 with a non-zero exit status.
498 The blocking size used in the archive volume where writing starts
499 will continue to be used for the remainder of that archive volume.
500 .Pp
501 .Sy Warning :
502 Many storage devices are not able to support the operations necessary
503 to perform an append operation.
504 Any attempt to append to an archive stored on such a device may damage the
505 archive or have other unpredictable results.
506 Tape drives in particular are more likely to not support an append operation.
507 An archive stored in a regular filesystem file or on a disk device will
508 usually support an append operation.
509 .It Fl B Ar bytes
510 Limit the number of bytes written to a single archive volume to
511 .Ar bytes .
512 The
513 .Ar bytes
514 limit can end with
515 .Sq Li m ,
516 .Sq Li k ,
517 or
518 .Sq Li b
519 to specify multiplication by 1048576 (1M), 1024 (1K) or 512, respectively.
520 A pair of
521 .Ar bytes
522 limits can be separated by
523 .Sq Li x
524 to indicate a product.
525 .Pp
526 .Sy Warning :
527 Only use this option when writing an archive to a device which supports
528 an end of file read condition based on last (or largest) write offset
529 (such as a regular file or a tape drive).
530 The use of this option with a floppy or hard disk is not recommended.
531 .It Fl b Ar blocksize
532 When writing an archive,
533 block the output at a positive decimal integer number of
534 bytes per write to the archive file.
535 The
536 .Ar blocksize
537 must be a multiple of 512 bytes with a maximum of 64512 bytes.
538 Archive block sizes larger than 32256 bytes violate the
539 .Tn POSIX
540 standard and will not be portable to all systems.
541 A
542 .Ar blocksize
543 can end with
544 .Sq Li k
545 or
546 .Sq Li b
547 to specify multiplication by 1024 (1K) or 512, respectively.
548 A pair of
549 .Ar blocksize Ns s
550 can be separated by
551 .Sq Li x
552 to indicate a product.
553 A specific archive device may impose additional restrictions on the size
554 of blocking it will support.
555 When blocking is not specified, the default
556 .Ar blocksize
557 is dependent on the specific archive format being used (see the
558 .Fl x
559 option).
560 .It Fl c
561 Match all file or archive members
562 .Em except
563 those specified by the
564 .Ar pattern
565 and
566 .Ar file
567 operands.
568 .It Fl D
569 This option is the same as the
570 .Fl u
571 option, except that the file inode change time is checked instead of the
572 file modification time.
573 The file inode change time can be used to select files whose inode information
574 (e.g., UID, GID, etc.) is newer than a copy of the file in the destination
575 .Ar directory .
576 .It Fl d
577 Cause files of type directory being copied or archived, or archive members of
578 type directory being extracted, to match only the directory file or archive
579 member and not the file hierarchy rooted at the directory.
580 .It Fl E Ar limit
581 Limit the number of consecutive read faults while trying to read a flawed
582 archive to
583 .Ar limit .
584 With a positive
585 .Ar limit ,
586 .Nm
587 will attempt to recover from an archive read error and will
588 continue processing starting with the next file stored in the archive.
589 A
590 .Ar limit
591 of 0 will cause
592 .Nm
593 to stop operation after the first read error is detected on an archive volume.
594 The default
595 .Ar limit
596 is a small positive number of retries.
597 .It Fl f Ar archive
598 Specify
599 .Ar archive
600 as the pathname of the input or output archive, overriding the default
601 standard input (for list and read)
602 or standard output
603 (for write).
604 A single archive may span multiple files and different archive devices.
605 When required,
606 .Nm
607 will prompt for the pathname of the file or device of the next volume in the
608 archive.
609 .It Fl G Ar group
610 Select a file based on its
611 .Ar group
612 name, or when starting with a
613 .Cm # ,
614 a numeric GID.
615 A
616 .Ql \e
617 can be used to escape the
618 .Cm # .
619 Multiple
620 .Fl G
621 options may be supplied and checking stops with the first match.
622 .It Fl H
623 Follow only command-line symbolic links while performing a physical file
624 system traversal.
625 .It Fl i
626 Interactively rename files or archive members.
627 For each archive member matching a
628 .Ar pattern
629 operand or each file matching a
630 .Ar file
631 operand,
632 .Nm
633 will prompt to
634 .Pa /dev/tty
635 giving the name of the file, its file mode, and its modification time.
636 .Nm
637 will then read a line from
638 .Pa /dev/tty .
639 If this line is blank, the file or archive member is skipped.
640 If this line consists of a single period, the
641 file or archive member is processed with no modification to its name.
642 Otherwise, its name is replaced with the contents of the line.
643 .Nm
644 will immediately exit with a non-zero exit status if
645 .Dv EOF
646 is encountered when reading a response or if
647 .Pa /dev/tty
648 cannot be opened for reading and writing.
649 .It Fl J
650 Use the xz utility to compress (decompress) the archive
651 while writing (reading).
652 Incompatible with
653 .Fl a .
654 .It Fl j
655 Use the bzip2 utility to compress (decompress) the archive
656 while writing (reading).
657 Incompatible with
658 .Fl a .
659 .It Fl k
660 Do not overwrite existing files.
661 .It Fl L
662 Follow all symbolic links to perform a logical filesystem traversal.
663 .It Fl l
664 (The lowercase letter
665 .Dq ell . )
666 Link files.
667 In copy mode
668 .Pq Fl r Fl w ,
669 hard links are made between the source and destination file hierarchies
670 whenever possible.
671 .It Fl M Ar flag
672 Configure the archive normaliser.
673 .Ar flag
674 is either a numeric value compatible to
675 .Xr strtonum 3
676 which is directly stored in the flags word, or
677 one of the following values, optionally prefixed with
678 .Dq no\-
679 to turn them off:
680 .Pp
681 .Bl -tag -width xxxxxx -compact
682 .It Ar inodes
683 0x0001: Serialise inodes, zero device info.
684 .br
685 (cpio, sv4cpio, sv4crc)
686 .It Ar links
687 0x0002: Store content of hard links only once.
688 .br
689 (cpio, sv4cpio, sv4crc)
690 .It Ar mtime
691 0x0004: Zero out the file modification time.
692 .br
693 (ar, cpio, sv4cpio, sv4crc, ustar)
694 .It Ar uidgid
695 0x0008: Set owner to 0:0
696 .Pq Li root Ns : Ns Li wheel .
697 .br
698 (ar, cpio, sv4cpio, sv4crc, ustar)
699 .It Ar verb
700 0x0010: Debug this option.
701 .It Ar debug
702 0x0020: Debug file header storage.
703 .It Ar lncp
704 0x0040: Extract hard links by copy if link fails.
705 .It Ar numid
706 0x0080: Use only numeric uid and gid values.
707 .br
708 (ustar)
709 .It Ar gslash
710 0x0100: Append a slash after directory names.
711 .br
712 (ustar)
713 .It Ar set
714 0x0003: Keep ownership and mtime intact.
715 .It Ar dist
716 0x008B: Clean everything except mtime.
717 .It Ar norm
718 0x008F: Clean everything.
719 .It Ar root
720 0x0089: Clean owner and device information.
721 .El
722 .Pp
723 When creating an archive and verbosely listing output, these
724 normalisation operations are not reflected in the output,
725 because they are made only after the output has been shown.
726 .Pp
727 This option is only implemented for the ar, cpio, sv4cpio,
728 sv4crc, and ustar file format writing routines.
729 .Pp
730 TODO: The
731 .Nm \*(nm
732 frontend should be using the
733 .Fl o
734 option for handling this feature instead.
735 .It Fl n
736 Select the first archive member that matches each
737 .Ar pattern
738 operand.
739 No more than one archive member is matched for each
740 .Ar pattern .
741 When members of type directory are matched, the file hierarchy rooted at that
742 directory is also matched (unless
743 .Fl d
744 is also specified).
745 .It Fl O
746 Force the archive to be one volume.
747 If a volume ends prematurely,
748 .Nm
749 will not prompt for a new volume.
750 This option can be useful for
751 automated tasks where error recovery cannot be performed by a human.
752 .It Fl o Ar options
753 Information to modify the algorithm for extracting or writing archive files
754 which is specific to the archive format specified by
755 .Fl x .
756 In general,
757 .Ar options
758 take the form:
759 .Ar name Ns = Ns Ar value .
760 .Pp
761 The following options are available for the
762 .Cm ustar
763 and old
764 .Bx
765 .Cm tar
766 formats:
767 .Pp
768 .Bl -tag -width Ds -compact
769 .It Cm write_opt=nodir
770 When writing archives, omit the storage of directories.
771 .El
772 .It Fl P
773 Do not follow symbolic links, perform a physical filesystem traversal.
774 This is the default mode.
775 .It Fl p Ar string
776 Specify one or more file characteristic options (privileges).
777 The
778 .Ar string
779 option-argument is a string specifying file characteristics to be retained or
780 discarded on extraction.
781 The string consists of the specification characters
782 .Cm a , e , m , o ,
783 and
784 .Cm p .
785 Multiple characteristics can be concatenated within the same string
786 and multiple
787 .Fl p
788 options can be specified.
789 The meanings of the specification characters are as follows:
790 .Bl -tag -width 2n
791 .It Cm a
792 Do not preserve file access times.
793 By default, file access times are preserved whenever possible.
794 .It Cm e
795 .Dq Preserve everything ,
796 the user ID, group ID, file mode bits,
797 file access time, and file modification time.
798 This is intended to be used by root,
799 someone with all the appropriate privileges, in order to preserve all
800 aspects of the files as they are recorded in the archive.
801 The
802 .Cm e
803 flag is the sum of the
804 .Cm o
805 and
806 .Cm p
807 flags.
808 .It Cm m
809 Do not preserve file modification times.
810 By default, file modification times are preserved whenever possible.
811 .It Cm o
812 Preserve the user ID and group ID.
813 .It Cm p
814 .Dq Preserve
815 the file mode bits.
816 This is intended to be used by a user with regular privileges
817 who wants to preserve all aspects of the file other than the ownership.
818 The file times are preserved by default, but two other flags are offered to
819 disable this and use the time of extraction instead.
820 .El
821 .Pp
822 In the preceding list,
823 .Sq preserve
824 indicates that an attribute stored in the archive is given to the
825 extracted file, subject to the permissions of the invoking
826 process.
827 Otherwise the attribute of the extracted file is determined as
828 part of the normal file creation action.
829 If neither the
830 .Cm e
831 nor the
832 .Cm o
833 specification character is specified, or the user ID and group ID are not
834 preserved for any reason,
835 .Nm
836 will not set the
837 .Dv S_ISUID
838 (setuid) and
839 .Dv S_ISGID
840 (setgid) bits of the file mode.
841 If the preservation of any of these items fails for any reason,
842 .Nm
843 will write a diagnostic message to standard error.
844 Failure to preserve these items will affect the final exit status,
845 but will not cause the extracted file to be deleted.
846 If the file characteristic letters in any of the string option-arguments are
847 duplicated or conflict with each other, the one(s) given last will take
848 precedence.
849 For example, if
850 .Fl p Ar eme
851 is specified, file modification times are still preserved.
852 .It Fl r
853 Read an archive file from standard input
854 and extract the specified
855 .Ar file
856 operands.
857 If any intermediate directories are needed in order to extract an archive
858 member, these directories will be created as if
859 .Xr mkdir 2
860 was called with the bitwise OR of
861 .Dv S_IRWXU , S_IRWXG ,
862 and
863 .Dv S_IRWXO
864 as the mode argument.
865 When the selected archive format supports the specification of linked
866 files and these files cannot be linked while the archive is being extracted,
867 .Nm
868 will write a diagnostic message to standard error
869 and exit with a non-zero exit status at the completion of operation.
870 .It Fl s Ar replstr
871 Modify the archive member names according to the substitution expression
872 .Ar replstr ,
873 using the syntax of the
874 .Xr ed 1
875 utility regular expressions.
876 .Ar file
877 or
878 .Ar pattern
879 arguments may be given to restrict the list of archive members to those
880 specified.
881 .Pp
882 The format of these regular expressions is:
883 .Pp
884 .Dl /old/new/[gp]
885 .Pp
886 As in
887 .Xr ed 1 ,
888 .Ar old
889 is a basic regular expression (see
890 .Xr re_format 7 )
891 and
892 .Ar new
893 can contain an ampersand
894 .Pq Ql & ,
895 .Ql \e Ns Em n
896 (where
897 .Em n
898 is a digit) back-references,
899 or subexpression matching.
900 The
901 .Ar old
902 string may also contain newline characters.
903 Any non-null character can be used as a delimiter
904 .Po
905 .Ql /
906 is shown here
907 .Pc .
908 Multiple
909 .Fl s
910 expressions can be specified.
911 The expressions are applied in the order they are specified on the
912 command line, terminating with the first successful substitution.
913 .Pp
914 The optional trailing
915 .Cm g
916 continues to apply the substitution expression to the pathname substring,
917 which starts with the first character following the end of the last successful
918 substitution.
919 The first unsuccessful substitution stops the operation of the
920 .Cm g
921 option.
922 The optional trailing
923 .Cm p
924 will cause the final result of a successful substitution to be written to
925 standard error in the following format:
926 .Pp
927 .D1 Em original-pathname No \*(Gt\*(Gt Em new-pathname
928 .Pp
929 File or archive member names that substitute to the empty string
930 are not selected and will be skipped.
931 .It Fl T Ar range
932 Allow files to be selected based on a file modification or inode change
933 time falling within the specified time range.
934 The range has the format:
935 .Sm off
936 .Bd -filled -offset indent
937 .Oo Ar from_date Oc Oo ,
938 .Ar to_date Oc Oo /
939 .Oo Cm c Oc Op Cm m Oc
940 .Ed
941 .Sm on
942 .Pp
943 The dates specified by
944 .Ar from_date
945 to
946 .Ar to_date
947 are inclusive.
948 If only a
949 .Ar from_date
950 is supplied, all files with a modification or inode change time
951 equal to or younger are selected.
952 If only a
953 .Ar to_date
954 is supplied, all files with a modification or inode change time
955 equal to or older will be selected.
956 When the
957 .Ar from_date
958 is equal to the
959 .Ar to_date ,
960 only files with a modification or inode change time of exactly that
961 time will be selected.
962 .Pp
963 When
964 .Nm
965 is in write or copy mode, the optional trailing field
966 .Oo Cm c Oc Ns Op Cm m
967 can be used to determine which file time (inode change, file modification or
968 both) are used in the comparison.
969 If neither is specified, the default is to use file modification time only.
970 The
971 .Cm m
972 specifies the comparison of file modification time (the time when
973 the file was last written).
974 The
975 .Cm c
976 specifies the comparison of inode change time (the time when the file
977 inode was last changed; e.g., a change of owner, group, mode, etc).
978 When
979 .Cm c
980 and
981 .Cm m
982 are both specified, then the modification and inode change times are
983 both compared.
984 .Pp
985 The inode change time comparison is useful in selecting files whose
986 attributes were recently changed or selecting files which were recently
987 created and had their modification time reset to an older time (as what
988 happens when a file is extracted from an archive and the modification time
989 is preserved).
990 Time comparisons using both file times is useful when
991 .Nm
992 is used to create a time based incremental archive (only files that were
993 changed during a specified time range will be archived).
994 .Pp
995 A time range is made up of six different fields and each field must contain two
996 digits.
997 The format is:
998 .Pp
999 .Dl [[[[[cc]yy]mm]dd]HH]MM[.SS]
1000 .Pp
1001 Where
1002 .Ar cc
1003 is the first two digits of the year (the century),
1004 .Ar yy
1005 is the last two digits of the year,
1006 the first
1007 .Ar mm
1008 is the month (from 01 to 12),
1009 .Ar dd
1010 is the day of the month (from 01 to 31),
1011 .Ar HH
1012 is the hour of the day (from 00 to 23),
1013 .Ar MM
1014 is the minute (from 00 to 59),
1015 and
1016 .Ar SS
1017 is the seconds (from 00 to 59).
1018 The minute field
1019 .Ar MM
1020 is required, while the other fields are optional and must be added in the
1021 following order:
1022 .Ar HH , dd , mm ,
1023 .Ar yy , cc .
1024 .Pp
1025 The
1026 .Ar SS
1027 field may be added independently of the other fields.
1028 Time ranges are relative to the current time, so
1029 .Ic \-T 1234/cm
1030 would select all files with a modification or inode change time
1031 of 12:34 PM today or later.
1032 Multiple
1033 .Fl T
1034 time range can be supplied and checking stops with the first match.
1035 .It Fl t
1036 Reset the access times of any file or directory read or accessed by
1037 .Nm
1038 to be the same as they were before being read or accessed by
1039 .Nm \*(nm .
1040 .It Fl U Ar user
1041 Select a file based on its
1042 .Ar user
1043 name, or when starting with a
1044 .Cm # ,
1045 a numeric UID.
1046 A
1047 .Ql \e
1048 can be used to escape the
1049 .Cm # .
1050 Multiple
1051 .Fl U
1052 options may be supplied and checking stops with the first match.
1053 .It Fl u
1054 Ignore files that are older (having a less recent file modification time)
1055 than a pre-existing file or archive member with the same name.
1056 During read,
1057 an archive member with the same name as a file in the filesystem will be
1058 extracted if the archive member is newer than the file.
1059 During write,
1060 a filesystem member with the same name as an archive member will be
1061 written to the archive if it is newer than the archive member.
1062 During copy,
1063 the file in the destination hierarchy is replaced by the file in the source
1064 hierarchy or by a link to the file in the source hierarchy if the file in
1065 the source hierarchy is newer.
1066 .It Fl v
1067 During a list operation, produce a verbose table of contents using the format of the
1068 .Xr ls 1
1069 utility with the
1070 .Fl l
1071 option.
1072 For pathnames representing a hard link to a previous member of the archive,
1073 the output has the format:
1074 .Pp
1075 .Dl Em ls \-l listing No == Em link-name
1076 .Pp
1077 For pathnames representing a symbolic link, the output has the format:
1078 .Pp
1079 .Dl Em ls \-l listing No -\*(Gt Em link-name
1080 .Pp
1081 Where
1082 .Em ls \-l listing
1083 is the output format specified by the
1084 .Xr ls 1
1085 utility when used with the
1086 .Fl l
1087 option.
1088 Otherwise for all the other operational modes
1089 (read, write, and copy),
1090 pathnames are written and flushed to standard error
1091 without a trailing newline
1092 as soon as processing begins on that file or
1093 archive member.
1094 The trailing newline
1095 is not buffered and is written only after the file has been read or written.
1096 .It Fl w
1097 Write files to the standard output
1098 in the specified archive format.
1099 When no
1100 .Ar file
1101 operands are specified, standard input
1102 is read for a list of pathnames with one per line without any leading or
1103 trailing
1104 .Aq blanks .
1105 .It Fl X
1106 When traversing the file hierarchy specified by a pathname,
1107 do not descend into directories that have a different device ID.
1108 See the
1109 .Li st_dev
1110 field as described in
1111 .Xr stat 2
1112 for more information about device IDs.
1113 .It Fl x Ar format
1114 Specify the output archive format, with the default format being
1115 .Cm ustar .
1116 .Nm
1117 currently supports the following formats:
1118 .Bl -tag -width "sv4cpio"
1119 .It Cm ar
1120 The Unix Archiver library format.
1121 This format matches APT repositories and the BSD
1122 .Xr ar 1
1123 specification, not GNU binutils (which can however read them) or SYSV systems.
1124 See
1125 .Xr ar 5
1126 on some operating systems for more information.
1127 .It Cm bcpio
1128 The old binary cpio format.
1129 The default blocksize for this format is 5120 bytes.
1130 This format is not very portable and should not be used when other formats
1131 are available.
1132 Inode and device information about a file (used for detecting file hard links
1133 by this format), which may be truncated by this format, is detected by
1134 .Nm
1135 and is repaired.
1136 .It Cm cpio
1137 The extended cpio interchange format specified in the
1138 .St -p1003.2
1139 standard.
1140 The default blocksize for this format is 5120 bytes.
1141 Inode and device information about a file (used for detecting file hard links
1142 by this format), which may be truncated by this format, is detected by
1143 .Nm
1144 and is repaired.
1145 .It Cm sv4cpio
1146 The System V release 4 cpio.
1147 The default blocksize for this format is 5120 bytes.
1148 Inode and device information about a file (used for detecting file hard links
1149 by this format), which may be truncated by this format, is detected by
1150 .Nm
1151 and is repaired.
1152 .It Cm sv4crc
1153 The System V release 4 cpio with file CRC checksums.
1154 The default blocksize for this format is 5120 bytes.
1155 Inode and device information about a file (used for detecting file hard links
1156 by this format), which may be truncated by this format, is detected by
1157 .Nm
1158 and is repaired.
1159 .It Cm tar
1160 The old
1161 .Bx
1162 tar format as found in
1163 .Bx 4.3 .
1164 The default blocksize for this format is 10240 bytes.
1165 Pathnames stored by this format must be 100 characters or less in length.
1166 Only regular files, hard links, symlinks and directories
1167 will be archived (other filesystem types are not supported).
1168 For backwards compatibility with even older tar formats, a
1169 .Fl o
1170 option can be used when writing an archive to omit the storage of directories.
1171 This option takes the form:
1172 .Pp
1173 .Dl Fl o Cm write_opt=nodir
1174 .It Cm ustar
1175 The extended tar interchange format specified in the
1176 .St -p1003.2
1177 standard.
1178 The default blocksize for this format is 10240 bytes.
1179 Filenames stored by this format must be 100 characters or less in length;
1180 the total pathname must be 256 characters or less.
1181 .El
1182 .Pp
1183 .Nm
1184 will detect and report any file that it is unable to store or extract
1185 as the result of any specific archive format restrictions.
1186 The individual archive formats may impose additional restrictions on use.
1187 Typical archive format restrictions include (but are not limited to):
1188 file pathname length, file size, link pathname length, and the type of the
1189 file.
1190 .It Fl Y
1191 This option is the same as the
1192 .Fl D
1193 option, except that the inode change time is checked using the
1194 pathname created after all the file name modifications have completed.
1195 .It Fl Z
1196 This option is the same as the
1197 .Fl u
1198 option, except that the modification time is checked using the
1199 pathname created after all the file name modifications have completed.
1200 .It Fl z
1201 Use the
1202 .Xr gzip 1
1203 utility to compress (decompress) the archive while writing (reading).
1204 Incompatible with
1205 .Fl a .
1206 .El
1207 .Pp
1208 The options that operate on the names of files or archive members
1209 .Po Fl c ,
1210 .Fl i ,
1211 .Fl n ,
1212 .Fl s ,
1213 .Fl u ,
1214 .Fl v ,
1215 .Fl D ,
1216 .Fl G ,
1217 .Fl T ,
1218 .Fl U ,
1219 .Fl Y ,
1220 and
1221 .Fl Z
1222 .Pc
1223 interact as follows.
1224 .Pp
1225 When extracting files during a read operation, archive members are
1226 .Sq selected ,
1227 based only on the user specified pattern operands as modified by the
1228 .Fl c ,
1229 .Fl n ,
1230 .Fl u ,
1231 .Fl D ,
1232 .Fl G ,
1233 .Fl T ,
1234 .Fl U
1235 options.
1236 Then any
1237 .Fl s
1238 and
1239 .Fl i
1240 options will modify in that order, the names of these selected files.
1241 Then the
1242 .Fl Y
1243 and
1244 .Fl Z
1245 options will be applied based on the final pathname.
1246 Finally, the
1247 .Fl v
1248 option will write the names resulting from these modifications.
1249 .Pp
1250 When archiving files during a write operation,
1251 or copying files during a copy operation,
1252 archive members are
1253 .Sq selected ,
1254 based only on the user specified pathnames as modified by the
1255 .Fl n ,
1256 .Fl u ,
1257 .Fl D ,
1258 .Fl G ,
1259 .Fl T ,
1260 and
1261 .Fl U
1262 options (the
1263 .Fl D
1264 option only applies during a copy operation).
1265 Then any
1266 .Fl s
1267 and
1268 .Fl i
1269 options will modify in that order, the names of these selected files.
1270 Then during a copy operation the
1271 .Fl Y
1272 and the
1273 .Fl Z
1274 options will be applied based on the final pathname.
1275 Finally, the
1276 .Fl v
1277 option will write the names resulting from these modifications.
1278 .Pp
1279 When one or both of the
1280 .Fl u
1281 or
1282 .Fl D
1283 options are specified along with the
1284 .Fl n
1285 option, a file is not considered selected unless it is newer
1286 than the file to which it is compared.
1287 .Sh ENVIRONMENT
1288 .Bl -tag -width Fl
1289 .It Ev TMPDIR
1290 Path in which to store temporary files.
1291 .El
1292 .Sh EXIT STATUS
1293 .Ex -std pax
1294 .Sh EXAMPLES
1295 Copy the contents of the current directory to the device
1296 .Pa /dev/rst0 :
1297 .Pp
1298 .Dl $ \*(nm \-w \-f /dev/rst0 \&.
1299 .Pp
1300 Give the verbose table of contents for an archive stored in
1301 .Pa filename :
1302 .Pp
1303 .Dl $ \*(nm \-v \-f filename
1304 .Pp
1305 This sequence of commands will copy the entire
1306 .Pa olddir
1307 directory hierarchy to
1308 .Pa newdir :
1309 .Bd -literal -offset indent
1310 $ mkdir newdir
1311 $ cd olddir
1312 $ \*(nm \-rw . ../newdir
1313 .Ed
1314 .Pp
1315 Extract files from the archive
1316 .Pa a.pax .
1317 Files rooted in
1318 .Pa /usr
1319 are extracted relative to the current working directory;
1320 all other files are extracted to their unmodified path.
1321 .Pp
1322 .Dl $ \*(nm \-r \-s \*(aq,\*(ha/usr/,,\*(aq \-f a.pax
1323 .Pp
1324 This can be used to interactively select the files to copy from the
1325 current directory to
1326 .Pa dest_dir :
1327 .Pp
1328 .Dl $ \*(nm \-rw \-i \&. dest_dir
1329 .Pp
1330 Extract all files from the archive
1331 .Pa a.pax
1332 which are owned by
1333 .Em root
1334 with group
1335 .Em bin
1336 and preserve all file permissions:
1337 .Pp
1338 .Dl "$ \*(nm \-r \-pe \-U root \-G bin \-f a.pax"
1339 .Pp
1340 Update (and list) only those files in the destination directory
1341 .Pa /backup
1342 which are older (less recent inode change or file modification times) than
1343 files with the same name found in the source file tree
1344 .Pa home :
1345 .Pp
1346 .Dl "$ \*(nm \-r \-w \-v \-Y \-Z home /backup"
1347 .Sh DIAGNOSTICS
1348 Whenever
1349 .Nm
1350 cannot create a file or a link when reading an archive or cannot
1351 find a file when writing an archive, or cannot preserve the user ID,
1352 group ID, or file mode when the
1353 .Fl p
1354 option is specified, a diagnostic message is written to standard error
1355 and a non-zero exit status will be returned, but processing will continue.
1356 In the case where
1357 .Nm
1358 cannot create a link to a file,
1359 unless
1360 .Fl M Ar lncp
1361 is given,
1362 .Nm
1363 will not create a second copy of the file.
1364 .Pp
1365 If the extraction of a file from an archive is prematurely terminated by
1366 a signal or error,
1367 .Nm
1368 may have only partially extracted a file the user wanted.
1369 Additionally, the file modes of extracted files and directories
1370 may have incorrect file bits, and the modification and access times may be
1371 wrong.
1372 .Pp
1373 If the creation of an archive is prematurely terminated by a signal or error,
1374 .Nm
1375 may have only partially created the archive, which may violate the specific
1376 archive format specification.
1377 .Pp
1378 If while doing a copy,
1379 .Nm
1380 detects a file is about to overwrite itself, the file is not copied,
1381 a diagnostic message is written to standard error
1382 and when
1383 .Nm
1384 completes it will exit with a non-zero exit status.
1385 .Sh SEE ALSO
1386 .Xr ar 1 ,
1387 .Xr cpio 1 ,
1388 .if \ng==1 \{\
1389 .Xr deb 5 ,
1390 .Xr mircpio 1 ,
1391 .Xr mirtar 1 ,
1392 .Xr pax 1 ,
1393 .\}
1394 .if \ng==2 \{\
1395 .Xr deb 5 ,
1396 .Xr paxcpio 1 ,
1397 .Xr paxtar 1 ,
1398 .\}
1399 .Xr tar 1
1400 .Sh STANDARDS
1401 The
1402 .Nm
1403 utility is mostly compliant with an older version of the IEEE Std 1003.1
1404 .Pq Dq Tn POSIX
1405 specification,
1406 except for the known
1407 .Sx BUGS
1408 listed below, and that the
1409 .Cm pax
1410 archive format and the
1411 .Cm listopt
1412 keyword are unsupported.
1413 .Pp
1414 The flags
1415 .Fl 0BDEGHJjLMOPTUYZz ,
1416 the archive formats
1417 .Cm ar ,
1418 .Cm bcpio ,
1419 .Cm sv4cpio ,
1420 .Cm sv4crc
1421 and
1422 .Cm tar ,
1423 the
1424 .Cm b , k ,
1425 and
1426 .Cm x
1427 additions to the
1428 .Fl b
1429 flag
1430 and the flawed archive handling during list and read operations
1431 are extensions to that specification.
1432 .Sh HISTORY
1433 A
1434 .Nm
1435 utility appeared in
1436 .Bx 4.4 .
1437 .Sh AUTHORS
1438 .An -nosplit
1439 .An Keith Muller
1440 at the University of California, San Diego.
1441 .Mx
1442 extensions by
1443 .An mirabilos Aq [email protected] .
1444 .Sh BUGS
1445 The pattern matching does not match either
1446 .Tn POSIX
1447 or this documentation completely.
1448 See also
1449 .Sx STANDARDS
1450 above.