/
tar.1
813 lines (813 loc) · 20.5 KB
/
tar.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
.\" $MirOS: src/bin/pax/tar.1,v 1.49 2024/01/05 02:08:49 tg Exp $
.\" $OpenBSD: tar.1,v 1.61 2018/07/23 19:02:49 kn Exp $
.\"
.\" Copyright © 2005, 2008, 2009, 2011, 2012, 2014, 2016,
.\" 2017, 2018, 2019, 2020, 2021
.\" mirabilos <m@mirbsd.org>
.\" Copyright (c) 1996 SigmaSoft, Th. Lockert
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"-
.\" $miros: contrib/samples/portmdoc,v 1.23 2024/01/04 22:52:50 tg Exp $
.\"-
.\" Copyright © 2008, 2009, 2010, 2016, 2018, 2020, 2023
.\" mirabilos <m@mirbsd.org>
.\"
.\" Glue GNU groff (BSD and GNU mdoc both) to AT&T nroff (UCB mdoc).
.\" * ` generates ‘ in gnroff, so use \`
.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
.\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
.\" thus use - for hyphens and \- for minus signs and option dashes
.\" * ~ is size-reduced and placed atop in groff, so use \*(TI
.\" * ^ is size-reduced and placed atop in groff, so use \*(ha
.\" * \(en does not work in nroff, so use \*(en for a solo en dash
.\" * and \*(EM for a correctly spaced em dash
.\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba
.\" Also make sure to use \& *before* a punctuation char that is to not
.\" be interpreted as punctuation, and especially with two-letter words
.\" but also (after) a period that does not end a sentence (“e.g.\&”).
.\"-
.\"
.\" Implement .Dd with the Mdocdate RCS keyword
.\"
.rn Dd xD
.de Dd
.ie \\$1$Mdocdate: \{\
. xD \\$2 \\$3, \\$4
.\}
.el .xD \\$1 \\$2 \\$3
..
.\"
.\" .Dd must come before most everything, because when called
.\" with -mandoc it loads -mdoc via .so in .Dd (first macro).
.\"
.Dd $Mdocdate: January 5 2024 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
.ie \n(.g \{\
. if n .ss \n[.ss] 0
. if \*[.T]ascii .tr \-\N'45'
. if \*[.T]latin1 .tr \-\N'45'
. if \*[.T]utf8 .tr \-\N'45'
. if \*[.T]utf8 .tr \(la\*(Lt
. if \*[.T]utf8 .tr \(ra\*(Gt
. ds <= \(<=
. ds >= \(>=
. ds Rq \(rq
. ds Lq \(lq
. ds sL \(aq
. ds sR \(aq
. if \*[.T]utf8 .ds sL `
. if \*[.T]ps .ds sL `
. if \*[.T]utf8 .ds sR '
. if \*[.T]ps .ds sR '
. ds aq \(aq
. ds TI \(ti
. ds ha \(ha
. ds en \(en
. ie d volume-ds-1 .ds tT gnu
. el .ie d doc-volume-ds-1 .ds tT gnp
. el .ds tT bsd
.\}
.el \{\
. ds aq '
. ds TI ~
. ds ha ^
. ds en \(em
. ds tT ucb
.\}
.ie n \{\
. ds EM \ \(em\ \&
.\}
.el \{\
. ds EM \f(TR\|\(em\|\fP
.\}
.\"
.\" Add UCB mdoc compatibility to GNU mdoc
.\" Implement .Mx (MirBSD)
.\"
.ie "\*(tT"gnu" \{\
. ds sP \s0
. ds tN \*[Tn-font-size]
. eo
. de Mx
. nr curr-font \n[.f]
. nr curr-size \n[.ps]
. ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
. ds str-Mx1 \*(tN\%MirBSD\*[str-Mx]
. if !\n[arg-limit] \
. if \n[.$] \{\
. ds macro-name Mx
. parse-args \$@
. \}
. if (\n[arg-limit] > \n[arg-ptr]) \{\
. nr arg-ptr +1
. ie (\n[type\n[arg-ptr]] == 2) \
. ds str-Mx1 \*(tN\%MirBSD\~#\*[arg\n[arg-ptr]]\*[str-Mx]
. el \
. nr arg-ptr -1
. \}
. ds arg\n[arg-ptr] "\*[str-Mx1]
. nr type\n[arg-ptr] 2
. ds space\n[arg-ptr] "\*[space]
. nr num-args (\n[arg-limit] - \n[arg-ptr])
. nr arg-limit \n[arg-ptr]
. if \n[num-args] \
. parse-space-vector
. print-recursive
..
. de Aq
. if !\n[arg-limit] \
. ds macro-name Aq
. ie \n[in-authors-section] \{\
. ds quote-left \*(Lt
. ds quote-right \*(Gt
. \}
. el \{\
. ds quote-left \[la]
. ds quote-right \[ra]
. \}
. enclose-string \$@
..
. ec
.\}
.el .ie "\*(tT"gnp" \{\
. ds sP \s0
. ie t .ds tN \s[(\n[.ps]u-1z)]
. el .ds tN
. eo
. de Mx
. nr doc-curr-font \n[.f]
. nr doc-curr-size \n[.ps]
. ds doc-str-Mx \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]
. ds doc-str-Mx1 \*(tN\%MirBSD\*[doc-str-Mx]
. if !\n[doc-arg-limit] \
. if \n[.$] \{\
. ds doc-macro-name Mx
. doc-parse-args \$@
. \}
. if (\n[doc-arg-limit] > \n[doc-arg-ptr]) \{\
. nr doc-arg-ptr +1
. ie (\n[doc-type\n[doc-arg-ptr]] == 2) \
. ds doc-str-Mx1 \*(tN\%MirBSD\~#\*[doc-arg\n[doc-arg-ptr]]\*[doc-str-Mx]
. el \
. nr doc-arg-ptr -1
. \}
. ds doc-arg\n[doc-arg-ptr] "\*[doc-str-Mx1]
. nr doc-type\n[doc-arg-ptr] 2
. ds doc-space\n[doc-arg-ptr] "\*[doc-space]
. nr doc-num-args (\n[doc-arg-limit] - \n[doc-arg-ptr])
. nr doc-arg-limit \n[doc-arg-ptr]
. if \n[doc-num-args] \
. doc-parse-space-vector
. doc-print-recursive
..
. ec
.\}
.el \{\
. de Mx
. nr cF \\n(.f
. nr cZ \\n(.s
. ds aa \&\f\\n(cF\s\\n(cZ
. if \\n(aC==0 \{\
. ie \\n(.$==0 \&\\*(tNMirBSD\\*(aa
. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
. \}
. if \\n(aC>\\n(aP \{\
. nr aP \\n(aP+1
. ie \\n(C\\n(aP==2 \{\
. nr xX 0
. nr xX 1+\\*(A\\n(aP
. as b1 \&\\*(tNMirBSD\ \&
. if \\n(xX>0 .as b1 #\&
. as b1 \&\\*(A\\n(aP\\*(aa
. rr xX
. ie \\n(aC>\\n(aP \{\
. nr aP \\n(aP+1
. nR
. \}
. el .aZ
. \}
. el \{\
. as b1 \&\\*(tNMirBSD\\*(aa
. nR
. \}
. \}
..
.\}
.\" </MirCVS://contrib/samples/portmdoc>
.\"-
.ie \ng==1 \{\
. ds nc mircpio
. ds np mirpax
. ds nt mirtar
. ds nm mirtar
. Dt MIRTAR 1
.\}
.el .ie \ng==2 \{\
. ds nc paxcpio
. ds np pax
. ds nt paxtar
. ds nm paxtar
. Dt PAXTAR 1
.\}
.el \{\
. ds nc cpio
. ds np pax
. ds nt tar
. ds nm tar
. Dt TAR 1
.\}
.\"-
.Os MirBSD
.Sh NAME
.ie \ng==1 \{\
.Nm mirtar
.Nd tape archiver
.\}
.el .ie \ng==2 \{\
.Nm paxtar
.Nd tape archiver
.\}
.el \{\
.Nm tar
.Nd tape archiver
.\}
.Sh SYNOPSIS
.Nm \*(nm
.Sm off
.No { Cm crtux No } Op Cm 014578abefHhJjLmOoPpqsvwXZz
.Sm on
.Op Ar blocking-factor \*(Ba archive \*(Ba replstr
.Op Fl C Ar directory
.Op Fl I Ar file
.Op Ar
.Pp
.Nm \*(nm
.No { Ns Fl crtux Ns }
.Bk -words
.Op Fl 014578aeHhJjLmOoPpqvwXZz
.Op Fl b Ar blocking-factor
.Op Fl C Ar directory
.Op Fl D Ar format-options
.Op Fl f Ar archive
.Op Fl I Ar file
.Op Fl M Ar flag
.Op Fl s Ar replstr
.Op Ar
.Ek
.Sh DESCRIPTION
The
.Nm
command creates, adds files to, or extracts files from an
archive file in
.Dq tar
.Pq strictly speaking, Cm ustar
format.
A tar archive is often stored on a magnetic tape, but can be
stored equally well on a floppy, CD-ROM, or in a regular disk file.
.Pp
In the first (legacy) form, all option flags except for
.Fl C
and
.Fl I
must be contained within the first argument to
.Nm
and must not be prefixed by a hyphen
.Pq Sq \-\& .
Option arguments, if any, are processed as subsequent arguments to
.Nm
and are processed in the order in which their corresponding option
flags have been presented on the command line.
.Pp
In the second and preferred form, option flags may be given in any order
and are immediately followed by their corresponding option argument
values.
.Pp
One of the following flags must be present:
.Bl -tag -width Ds
.It Fl c
Create new archive, or overwrite an existing archive,
adding the specified files to it.
.It Fl r
Append the named new files to existing archive.
Note that this will only work on media on which an end-of-file mark
can be overwritten.
.It Fl t
List contents of archive.
If any files are named on the
command line, only those files will be listed.
The
.Ar file
arguments may be specified as glob patterns (see
.Xr glob 7
for more information), in which case
.Nm
will list all archive members that match each pattern.
.It Fl u
Alias for
.Fl r .
.It Fl x
Extract files from archive.
If any files are named on the
command line, only those files will be extracted from the
archive.
The
.Ar file
arguments may be specified as glob patterns (see
.Xr glob 7
for more information), in which case
.Nm
will extract all archive members that match each pattern.
.Pp
If more than one copy of a file exists in the
archive, later copies will overwrite earlier copies during
extraction.
The file mode and modification time are preserved
if possible.
The file mode is subject to modification by the
.Xr umask 2 .
.El
.Pp
In addition to the flags mentioned above, any of the following
flags may be used:
.Bl -tag -width Ds
.It Fl a
Guess the compression utility based on the archive filename.
Inability to guess will result in quietly not using any compression.
This option only exists for semi-compatibility with
.Tn GNU
.Nm tar ;
it is strongly recommended to archive to stdout and pipe into
an external compression utility with appropriate arguments instead:
.Pp
.Dl tar \-cf \- foo \*(Ba xz \-2e \*(Gtfoo.txz
.It Fl b Ar blocking-factor
Set blocking factor to use for the archive.
.Nm
uses 512-byte blocks.
The default is 20, the maximum is 126.
Archives with a blocking factor larger than 63 violate the
.Tn POSIX
standard and will not be portable to all systems.
.It Fl C Ar directory
This is a positional argument which sets the working directory for the
following files.
When extracting, files will be extracted into
the specified directory; when creating, the specified files will be matched
from the directory.
.It Fl D Ar format-options
Specify the archive format and format options, separated by comma.
.Nm
currently supports the following formats and options:
.Bl -tag -width "sv4cpio"
.It Cm ar
The Unix Archiver library format.
This format matches APT repositories and the BSD
.Xr ar 1
specification, not GNU binutils (which can however read them) or SYSV systems.
See
.Xr ar 5
on some operating systems for more information.
.It Cm bcpio
The old binary cpio format.
The default blocksize for this format is 5120 bytes.
This format is not very portable and should not be used when other formats
are available.
Inode and device information about a file (used for detecting file hard links
by this format), which may be truncated by this format, is detected by
.Nm
and is repaired.
.It Cm cpio
The extended cpio interchange format specified in the
.St -p1003.2
standard.
The default blocksize for this format is 5120 bytes.
Inode and device information about a file (used for detecting file hard links
by this format), which may be truncated by this format, is detected by
.Nm
and is repaired.
.It Cm sv4cpio
The System V release 4 cpio.
The default blocksize for this format is 5120 bytes.
Inode and device information about a file (used for detecting file hard links
by this format), which may be truncated by this format, is detected by
.Nm
and is repaired.
.It Cm sv4crc
The System V release 4 cpio with file CRC checksums.
The default blocksize for this format is 5120 bytes.
Inode and device information about a file (used for detecting file hard links
by this format), which may be truncated by this format, is detected by
.Nm
and is repaired.
.It Cm tar
The old
.Bx
tar format as found in
.Bx 4.3 .
The default blocksize for this format is 10240 bytes.
Pathnames stored by this format must be 100 characters or less in length.
Only regular files, hard links, symlinks and directories
will be archived (other filesystem types are not supported).
.Pp
For backwards compatibility with even older tar formats, the
.Cm write_opt=nodir
option can be used when writing an archive to omit the storage of directories.
.It Cm ustar
The extended tar interchange format specified in the
.St -p1003.2
standard.
The default blocksize for this format is 10240 bytes.
Filenames stored by this format must be 100 characters or less in length;
the total pathname must be 256 characters or less.
.El
.Pp
.Nm
will detect and report any file that it is unable to store or extract
as the result of any specific archive format restrictions.
The individual archive formats may impose additional restrictions on use.
Typical archive format restrictions include (but are not limited to):
file pathname length, file size, link pathname length, and the type of the
file.
.It Fl e
Stop after the first error.
.It Fl f Ar archive
Filename where the archive is stored.
Defaults to
.Pa /dev/rst0 .
If set to hyphen
.Pq Sq \-\&
standard output is used.
See also the
.Ev TAPE
environment variable.
.It Fl H
Follow symlinks given on the command line only.
.It Fl h
Follow symbolic links as if they were normal files
or directories.
In extract mode this means that a directory entry in the archive
will not overwrite an existing symbolic link, but rather what the
link ultimately points to.
.It Fl I Ar file
This is a positional argument which reads the names of files to
archive or extract from the given file, one per line.
.It Fl J
Use the xz utility to compress the archive.
.It Fl j
Use the bzip2 utility to compress the archive.
.It Fl L
Synonym for the
.Fl h
option.
.It Fl M Ar flag
Configure the archive normaliser.
.Ar flag
is either a numeric value compatible to
.Xr strtonum 3
which is directly stored in the flags word, or
one of the following values, optionally prefixed with
.Dq no\-
to turn them off:
.Pp
.Bl -tag -width xxxxxx -compact
.It Ar inodes
0x0001: Serialise inodes, zero device info.
.br
(cpio, sv4cpio, sv4crc)
.It Ar links
0x0002: Store content of hard links only once.
.br
(cpio, sv4cpio, sv4crc)
.It Ar mtime
0x0004: Zero out the file modification time.
.br
(ar, cpio, sv4cpio, sv4crc, ustar)
.It Ar uidgid
0x0008: Set owner to 0:0
.Pq Li root Ns : Ns Li wheel .
.br
(ar, cpio, sv4cpio, sv4crc, ustar)
.It Ar verb
0x0010: Debug this option.
.It Ar debug
0x0020: Debug file header storage.
.It Ar lncp
0x0040: Extract hard links by copy if link fails.
.It Ar numid
0x0080: Use only numeric uid and gid values.
.br
(ustar)
.It Ar gslash
0x0100: Append a slash after directory names.
.br
(ustar)
.It Ar set
0x0003: Keep ownership and mtime intact.
.It Ar dist
0x008B: Clean everything except mtime.
.It Ar norm
0x008F: Clean everything.
.It Ar root
0x0089: Clean owner and device information.
.El
.Pp
When creating an archive and verbosely listing output, these
normalisation operations are not reflected in the output,
because they are made only after the output has been shown.
.Pp
This option is only implemented for the ar, cpio, sv4cpio,
sv4crc, and ustar file format writing routines.
.It Fl m
Do not preserve modification time.
.It Fl O
If reading, extract files to standard output.
.br
If writing, write old-style (non-POSIX) archives.
.It Fl o
If writing, write old-style (non-POSIX) archives.
.br
Don't write directory information that the older (V7) style
.Nm tar
is unable to decode.
Same as
.Fl D Ar tar,write_opt=nodir .
.It Fl P
For security reasons,
.Nm
skips pathnames containing dotdot
.Pq Dq ..\&
components and strips leading slashes
.Pq Sq /
from pathnames by default; this option disables that behaviour.
.It Fl p
Preserve user and group ID as well as file mode regardless of
the current
.Xr umask 2 .
The setuid and setgid bits are only preserved if the user and group ID
could be preserved.
Only meaningful in conjunction with the
.Fl x
flag.
.It Fl q
Select the first archive member that matches each
.Ar file
operand.
No more than one archive member is matched for each
.Ar file .
When members of type directory are matched, the file hierarchy rooted at that
directory is also matched.
.It Fl s Ar replstr
Modify the archive member names according to the substitution expression
.Ar replstr ,
using the syntax of the
.Xr ed 1
utility regular expressions.
.Ar file
arguments may be given to restrict the list of archive members to those
specified.
.Pp
The format of these regular expressions is
.Pp
.Dl /old/new/[gp]
.Pp
As in
.Xr ed 1 ,
.Va old
is a basic regular expression (see
.Xr re_format 7 )
and
.Va new
can contain an ampersand
.Pq Ql & ,
.Ql \e Ns Em n
(where
.Em n
is a digit) back-references,
or subexpression matching.
The
.Va old
string may also contain newline characters.
Any non-null character can be used as a delimiter
.Po
.Ql /
is shown here
.Pc .
Multiple
.Fl s
expressions can be specified.
The expressions are applied in the order they are specified on the
command line, terminating with the first successful substitution.
.Pp
The optional trailing
.Cm g
continues to apply the substitution expression to the pathname substring,
which starts with the first character following the end of the last successful
substitution.
The first unsuccessful substitution stops the operation of the
.Cm g
option.
The optional trailing
.Cm p
will cause the final result of a successful substitution to be written to
standard error in the following format:
.Pp
.D1 Em original-pathname No \*(Gt\*(Gt Em new-pathname
.Pp
File or archive member names that substitute to the empty string
are not selected and will be skipped.
.It Fl v
Verbose operation mode.
If
.Fl v
is specified multiple times or if the
.Fl t
option is also specified,
.Nm
will use a long format for listing files, similar to
.Xr ls 1
.Fl l .
.It Fl w
Interactively rename files.
This option causes
.Nm
to prompt the user for the filename to use when storing or
extracting files in an archive.
.It Fl X
Do not cross mount points in the filesystem.
.It Fl Z
Use the
.Xr compress 1
utility to compress the archive.
.It Fl z
Use the
.Xr gzip 1
utility to compress the archive.
.El
.Pp
The options
.Op Fl 014578
can be used to select one of the compiled-in backup devices,
.Pa /dev/rstN .
.Sh ENVIRONMENT
.Bl -tag -width Fl
.It Ev TMPDIR
Path in which to store temporary files.
.It Ev TAPE
Default tape device to use instead of
.Pa /dev/rst0 .
If set to hyphen
.Pq Sq \-\&
standard output is used.
.El
.Sh FILES
.Bl -tag -width "/dev/rst0"
.It Pa /dev/rst0
default archive name
.El
.Sh EXIT STATUS
The
.Nm
utility exits with one of the following values:
.Pp
.Bl -tag -width Ds -offset indent -compact
.It 0
All files were processed successfully.
.It 1
An error occurred.
.El
.Sh EXAMPLES
Create an archive on the default tape drive, containing the files named
.Pa bonvole
and
.Pa sekve :
.Pp
.Dl $ \*(nm c bonvole sekve
.Pp
Output a
.Xr gzip 1
compressed archive containing the files
.Pa bonvole
and
.Pa sekve
to a file called
.Pa foriru.tar.gz :
.Pp
.Dl $ \*(nm zcf foriru.tar.gz bonvole sekve
.Pp
Verbosely create an archive, called
.Pa backup.tar.gz ,
of all files matching the shell
.Xr glob 7
function
.Pa *.c :
.Pp
.Dl $ \*(nm zcvf backup.tar.gz *.c
.Pp
Verbosely list, but do not extract, all files ending in
.Pa .jpeg
from a compressed archive named
.Pa backup.tar.gz .
Note that the glob pattern has been quoted to avoid expansion by the shell:
.Pp
.Dl $ \*(nm tvzf backup.tar.gz \*(aq*.jpeg\*(aq
.Pp
For more detailed examples, see
.Xr \*(np 1 .
.Sh DIAGNOSTICS
Whenever
.Nm
cannot create a file or a link when extracting an archive or cannot
find a file while writing an archive, or cannot preserve the user
ID, group ID, file mode, or access and modification times when the
.Fl p
option is specified, a diagnostic message is written to standard
error and a non-zero exit value will be returned, but processing
will continue.
In the case where
.Nm
cannot create a link to a file,
unless
.Fl M Ar lncp
is given,
.Nm
will not create a second copy of the file.
.Pp
If the extraction of a file from an archive is prematurely terminated
by a signal or error,
.Nm
may have only partially extracted the file the user wanted.
Additionally, the file modes of extracted files and directories may
have incorrect file bits, and the modification and access times may
be wrong.
.Pp
If the creation of an archive is prematurely terminated by a signal
or error,
.Nm
may have only partially created the archive, which may violate the
specific archive format specification.
.Sh SEE ALSO
.Xr ar 1 ,
.Xr cpio 1 ,
.ie \ng==1 \{\
.Xr mircpio 1 ,
.Xr mirpax 1 ,
.Xr pax 1 ,
.Xr tar 1 ,
.Xr deb 5
.\}
.el .ie \ng==2 \{\
.Xr pax 1 ,
.Xr paxcpio 1 ,
.Xr tar 1 ,
.Xr deb 5
.\}
.el \{\
.Xr pax 1
.\}
.Sh HISTORY
A
.Nm tar
command first appeared in
.At v7 .
.Sh AUTHORS
.An -nosplit
.An Keith Muller
at the University of California, San Diego.
.Mx
extensions by
.An mirabilos Aq m@mirbsd.org .
.Sh CAVEATS
The flags
.Fl aDJjLMo
are not portable to other implementations of
.Nm tar
where they may have a different meaning or not exist at all.
.Pp
This implementation may have support for other non-standard options that
are undocumented because removal-inducing deprecation was issued.
.Sh BUGS
The
.Ar pax
file format is not yet supported.