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