Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / usr.bin / tar / tar.1
1 .\" Copyright (c) 1991, 1992, 1993 Free Software Foundation     -*- nroff -*-
2 .\" See /usr/src/gnu/COPYING for conditions of redistribution
3 .\"
4 .\"     Written by John F. Woods <jfw@jfwhome.funhouse.com>
5 .\"     Updated by Robert Eckardt <roberte@mep.ruhr-uni-bochum.de>
6 .\"
7 .\" $FreeBSD: src/gnu/usr.bin/tar/tar.1,v 1.22.2.13 2003/02/23 18:08:58 keramida Exp $
8 .\" $DragonFly: src/gnu/usr.bin/tar/Attic/tar.1,v 1.2 2003/06/17 04:25:49 dillon Exp $
9 .\"
10 .Dd December 23, 2000
11 .Os
12 .Dt TAR 1
13 .Sh NAME
14 .Nm tar
15 .Nd "tape archiver; manipulate ""tar"" archive files"
16 .Sh SYNOPSIS
17 .Nm
18 .Op Oo Fl Oc Ns Ar bundled-options Ar Args
19 .Op Ar gnu-style-flags
20 .Op Ar filenames | Fl C Ar directory-name
21 .Ar ...
22 .Sh DESCRIPTION
23 .Nm Tar
24 is short for 
25 .Dq tape archiver ,
26 so named for historical reasons; the
27 .Nm
28 program creates, adds files to, or extracts files from an archive file
29 in
30 .Nm
31 format, called a
32 .Ar tarfile .
33 A
34 .Ar tarfile
35 is often a magnetic tape, but can be a floppy diskette or any
36 regular disk file.
37 .Pp
38 The first argument word of the
39 .Nm
40 command line is usually a command word of bundled function and modifier
41 letters, optionally preceded by a dash;
42 it must contain exactly one function letter from the set
43 .Cm A ,
44 .Cm c ,
45 .Cm d ,
46 .Cm r ,
47 .Cm t ,
48 .Cm u ,
49 .Cm x ,
50 for
51 .Em append ,
52 .Em create ,
53 .Em difference ,
54 .Em replace ,
55 .Em table of contents ,
56 .Em update ,
57 and
58 .Em extract
59 (further described below).
60 The command word can also contain other function modifiers described below,
61 some of which will take arguments from the command line in the order they
62 are specified in the command word (review the
63 .Sx EXAMPLES
64 section).
65 Functions and function modifiers can also be specified
66 with the GNU argument convention (preceded by two dashes, one function or
67 modifier per word.
68 Command-line arguments that specify files to
69 add to, extract from, or list from an archive may be given as shell
70 pattern matching strings.
71 .Sh FUNCTIONS
72 Exactly one of the following functions must be specified.
73 .Pp
74 .Bl -tag -width "--concatenate" -compact
75 .It Fl A
76 .It Fl -catenate
77 .It Fl "-concatenate"
78 Append the contents of named file, which must itself be a
79 .Nm
80 archive,
81 to the end of the archive (erasing the old end-of-archive block).
82 This has the effect of adding the files contained in the named file to
83 the first archive, rather than adding the second archive as an element
84 of the first.
85 .Em Note :
86 This option requires a rewritable
87 .Ar tarfile ,
88 and therefore does not work on quarter-inch cartridge tapes.
89 .It Fl c
90 .It Fl -create
91 Create a new archive (or truncates an old one) and writes the named files
92 to it.
93 .It Fl d
94 .It Fl -diff
95 .It Fl -compare
96 Find differences between files in the archive and corresponding files in
97 the file system.
98 .It Fl -delete
99 Delete named files from the archive.
100 (Does not work on quarter-inch tapes).
101 .It Fl r
102 .It Fl -append
103 Append files to the end of an archive.
104 (Does not work on quarter-inch tapes).
105 .It Fl t
106 .It Fl -list
107 List the contents of an archive; if
108 .Ar filename
109 arguments are given, only those
110 files are listed, otherwise the entire table of contents is listed.
111 .It Fl u
112 .It Fl -update
113 Append the named files if the on-disk version has a modification date
114 more recent than their copy in the archive (if any).
115 Does not work on quarter-inch tapes.
116 .It Fl x
117 .It Fl -extract
118 .It Fl -get
119 Extract files from an archive.
120 The owner, modification time, and file permissions are restored, if possible.
121 If no
122 .Ar file
123 arguments are given, extract all the files in the archive.
124 If a
125 .Ar filename
126 argument matches the name of a directory on the tape, that directory and
127 its contents are extracted (as well as all directories under that directory).
128 If the archive contains multiple entries corresponding to the same file
129 (see the
130 .Fl -append
131 command above), the last one extracted will overwrite all earlier versions.
132 .El
133 .Sh OPTIONS
134 The other options to
135 .Nm
136 may be combined arbitrarily; single-letter options may be bundled in with
137 the command word.
138 Verbose options which take arguments will be
139 followed by the argument; single-letter options will consume
140 successive command line arguments (see the
141 .Sx EXAMPLES
142 below).
143 .Pp
144 .Bl -tag -width "--preserve-permissions" -compact
145 .It Fl -help
146 Prints a message listing and briefly describing all the command
147 options to
148 .Nm .
149 .It Fl -atime-preserve
150 Restore the access times on files which are written to tape (note that
151 this will change the inode-change time!).
152 .It Fl b
153 .It Fl -block-size Ar number
154 Sets the block size for reading or writing to
155 .Ar number
156 * 512-byte blocks.
157 .It Fl B
158 .It Fl -read-full-blocks
159 Re-assemble short reads into full blocks (for reading
160 .Bx 4.2
161 pipes).
162 .It Fl C Ar directory
163 .It Fl -directory Ar directory
164 Change to
165 .Ar directory
166 before processing the remaining arguments.
167 .It Fl -checkpoint
168 Print number of buffer reads/writes while reading/writing the archive.
169 .It Fl f Xo
170 .Oo Ar hostname : Oc Ns Ar file
171 .Xc
172 .It Fl -file Xo
173 .Oo Ar hostname : Oc Ns Ar file
174 .Xc
175 Read or write the specified
176 .Ar file
177 (default is
178 .Pa /dev/sa0 ) .
179 If a
180 .Ar hostname
181 is specified,
182 .Nm
183 will use
184 .Xr rmt 8
185 to read or write the specified
186 .Ar file
187 on a remote machine.
188 .Dq Ar -
189 may be used as a filename, for reading
190 or writing to/from stdin/stdout.
191 .It Fl -force-local
192 Archive file is local even if it has a colon.
193 .It Fl F Ar file
194 .It Fl -info-script Ar file
195 .It Fl -new-volume-script Ar file
196 Run a script at the end of each archive volume (implies
197 .Fl M ) .
198 .It Fl -fast-read
199 Stop after all non-wildcard extraction targets have been found
200 in the archive.
201 .It Fl G
202 .It Fl -incremental
203 Create/list/extract old GNU-format incremental backup.
204 .It Fl g Ar file
205 .It Fl -listed-incremental Ar file
206 Create/list/extract new GNU-format incremental backup.
207 .It Fl h
208 .It Fl -dereference
209 Don't write symlinks as symlinks; write the data of the files they name.
210 .It Fl i
211 .It Fl -ignore-zeros
212 Ignore blocks of zeroes in archive (usually means End-Of-File).
213 .It Fl -ignore-failed-read
214 Don't exit with non-zero status on unreadable files.
215 .It Fl j
216 .It Fl y
217 .It Fl -bzip
218 .It Fl -bzip2
219 .It Fl -bunzip2
220 Filter the archive through
221 .Xr bzip2 1 .
222 .It Fl k
223 .It Fl -keep-old-files
224 Keep files which already exist on disk; don't overwrite them from the archive.
225 .It Fl K Ar file
226 .It Fl -starting-file Ar file
227 Begin at
228 .Ar file
229 in the archive.
230 .It Fl l
231 .It Fl -one-file-system
232 Stay in local file system when creating an archive (do not cross mount
233 points).
234 .It Fl L Ar number
235 .It Fl -tape-length Ar number
236 Change tapes after writing 
237 .Ar number
238 * 1024 bytes.
239 .It Fl m
240 .It Fl -modification-time
241 Don't extract file modified time.
242 .It Fl M
243 .It Fl -multi-volume
244 Create/list/extract multi-volume archive.
245 .It Fl n
246 .It Fl -norecurse
247 Don't recurse into subdirectories when creating.
248 .It Fl -volno-file Ar file
249 File name with volume number to start with.
250 .It Fl N Ar date
251 .It Fl -after-date Ar date
252 .It Fl -newer Ar date
253 Only store files with creation time newer than
254 .Ar date .
255 .It Fl -newer-mtime Ar date
256 Only store files with modification time newer than
257 .Ar date .
258 .It Fl o
259 .It Fl -old-archive
260 .It Fl -portability
261 Write a V7 format archive, rather than POSIX format.
262 .It Fl O
263 .It Fl -to-stdout
264 Extract files to standard output.
265 .It Fl p
266 .It Fl -same-permissions
267 .It Fl -preserve-permissions
268 Extract all protection information.
269 .It Fl -preserve
270 Has the effect of
271 .Fl p s .
272 .It Fl P
273 .It Fl -absolute-paths
274 Don't strip leading
275 .Ql /
276 from file names.
277 .It Fl R
278 .It Fl -record-number
279 Show record number within archive with each message.
280 .It Fl -remove-files
281 Remove files after adding them to the archive.
282 .It Fl s
283 .It Fl -same-order
284 .It Fl -preserve-order
285 List of names to extract is sorted to match archive.
286 .It Fl -show-omitted-dirs
287 Show directories which were omitted while processing the archive.
288 .It Fl S
289 .It Fl -sparse
290 Handle
291 .Dq sparse
292 files efficiently.
293 .It Fl T Ar file
294 .It Fl I Ar file
295 .It Fl -files-from Ar file
296 Get names of files to extract or create from
297 .Ar file ,
298 one per line.
299 .It Fl -null
300 Modifies behavior of
301 .Fl T
302 to expect null-terminated names; disables
303 .Fl C .
304 .It Fl -totals
305 Prints total bytes written with
306 .Fl -create .
307 .It Fl U
308 .It Fl -unlink
309 .It Fl -unlink-first
310 Unlink files before creating them.
311 .It Fl v
312 .It Fl -verbose
313 Lists files written to archive with
314 .Fl -create
315 or extracted with
316 .Fl -extract ;
317 lists file protection information along with file names with
318 .Fl -list .
319 .It Fl V Ar volume-name
320 .It Fl -label Ar volume-name
321 Create archive with the given
322 .Ar volume-name .
323 .It Fl -version
324 Print
325 .Nm
326 program version number.
327 .It Fl w
328 .It Fl -interactive
329 .It Fl -confirmation
330 Ask for confirmation for every action.
331 .It Fl W
332 .It Fl -verify
333 Attempt to verify the archive after writing it.
334 .It Fl -exclude Ar pattern
335 Exclude files matching the
336 .Ar pattern
337 (don't extract them, don't add them, don't list them).
338 .It Fl X Ar file
339 .It Fl -exclude-from Ar file
340 Exclude files listed in
341 .Ar file .
342 .It Fl Z
343 .It Fl -compress
344 .It Fl -uncompress
345 Filter the archive through
346 .Xr compress 1 .
347 .It Fl z
348 .It Fl -gzip
349 .It Fl -gunzip
350 Filter the archive through
351 .Xr gzip 1 .
352 .It Fl -use-compress-program Ar program
353 Filter the archive through
354 .Ar program
355 (which must accept
356 .Fl d
357 to mean
358 .Dq decompress ) .
359 .It Fl -block-compress
360 Block the output of compression program for tapes or floppies
361 (otherwise writes will be of odd length, which device drivers may reject).
362 .It Fl Xo
363 .Op Cm 0 Ns - Ns Cm 7 Ns
364 .Op Cm lmh
365 .Xc
366 Specify tape drive and density.
367 .El
368 .Sh ENVIRONMENT
369 The environment variable
370 .Ev TAR_OPTIONS
371 can hold a set of default options for
372 .Nm .
373 These options are interpreted first and can be overwritten by explicit command
374 line parameters.
375 .Sh EXAMPLES
376 To create an archive on tape drive
377 .Pa /dev/sa0
378 with a block size of 20 blocks, containing files named
379 .Pa bert
380 and
381 .Pa ernie ,
382 you can enter
383 .Dl "tar cfb /dev/sa0 20 bert ernie"
384 or
385 .Dl "tar --create --file /dev/sa0 --block-size 20 bert ernie"
386 Note that the
387 .Fl f
388 and
389 .Fl b
390 flags both require arguments, which they take from the command line in
391 the order they were listed in the command word.
392 .Pp
393 Because
394 .Pa /dev/sa0
395 is the default device, and 20 is the default block
396 size, the above example could have simply been
397 .Dl "tar c bert ernie"
398 .Pp
399 To extract all the C sources and headers from an archive named
400 .Pa backup.tar ,
401 type
402 .Dl "tar xf backup.tar '*.[ch]'"
403 Note that the pattern must be quoted to prevent the shell from
404 attempting to expand it according the files in the current working
405 directory (the shell does not have access to the list of files in
406 the archive, of course).
407 .Pp
408 To move file hierarchies, use a command line like this:
409 .Bd -literal
410 tar -cf - -C srcdir . | tar xpf - -C destdir
411 .Ed
412 .Pp
413 To create a compressed archive on diskette, using
414 .Xr gzip 1 ,
415 use a command-line like
416 .Dl "tar --block-compress -z -c -v -f /dev/fd1a -b 36 tar/"
417 .Pp
418 Note that you cannot mix bundled flags and
419 .Fl -style
420 flags; you can use
421 single-letter flags in the manner above, rather than having to type
422 .Dl "tar --block-compress --gzip --verbose --file /dev/fd1a --block-size 20 tar/"
423 .Pp
424 The above-created diskette can be listed with
425 .Dl "tar tvfbz /dev/fd1a 36"
426 .Pp
427 To join two
428 .Nm
429 archives into a single archive, use
430 .Dl "tar Af archive1.tar archive2.tar"
431 which will add the files contained in
432 .Pa archive2.tar
433 onto the end of
434 .Pa archive1.tar
435 (note that this can't be done by simply typing
436 .Dl "cat archive2.tar >> archive1.tar"
437 because of the end-of-file block at the end of a
438 .Nm
439 archive).
440 .Pp
441 To archive all files from the directory
442 .Pa srcdir ,
443 which were modified
444 after Feb. 9th 1997, 13:00 h, use
445 .Dl "tar -c -f backup.tar --newer-mtime 'Feb 9 13:15 1997' srcdir/"
446 .Pp
447 Other possible time specifications are
448 .Sq "02/09/97 13:15" ,
449 .Sq "1997-02-09 13:15" ,
450 .Sq "13:15 9 Feb 1997" ,
451 .Sq "9 Feb 1997 13:15" , 
452 .Sq "Feb. 9, 1997 1:15pm" ,
453 .Sq "09-Feb" ,
454 .Sq "3 weeks ago"
455 or
456 .Sq "May first Sunday" .
457 To specify the correct time zone use either e.g.\&
458 .Sq "13:15 CEST"
459 or
460 .Sq "13:15+200" .
461 .Sh ENVIRONMENT
462 The
463 .Nm
464 program examines the following environment variables.
465 .Bl -tag -width "POSIXLY_CORRECT"
466 .It Ev POSIXLY_CORRECT
467 Normally,
468 .Nm
469 will process flag arguments that appear in the file list.
470 If set in the environment, this causes
471 .Nm
472 to consider the first
473 non-flag argument to terminate flag processing, as per the POSIX specification.
474 .It Ev SHELL
475 In interactive mode, a permissible response to the prompt is to
476 request to spawn a subshell, which will be
477 .Pa /bin/sh
478 unless the
479 .Ev SHELL
480 variable is set.
481 .It Ev TAPE
482 Changes
483 .Nm Ns 's
484 default tape drive (which is still overridden by the
485 .Fl f
486 flag).
487 .It TAR_RSH
488 The TAR_RSH environment variable allows you to override the default
489 shell used as the transport for
490 .Nm .
491 .El
492 .Sh FILES
493 .Bl -tag -width "/dev/sa0"
494 .It Pa /dev/sa0
495 The default tape drive.
496 .El
497 .Sh COMPATIBILITY
498 The
499 .Fl y
500 is a
501 .Fx
502 localism.
503 The GNU
504 .Nm
505 maintainer has now chosen
506 .Fl j
507 as the offical
508 .Xr bzip2 1
509 compression option in GNU
510 .Nm
511 1.13.18 and later.
512 The
513 .Fl I
514 option is for compatibility with Solaris's
515 .Nm .
516 .Sh SEE ALSO
517 .Xr bzip2 1 ,
518 .Xr compress 1 ,
519 .Xr gzip 1 ,
520 .Xr pax 1 ,
521 .Xr rmt 8
522 .Sh HISTORY
523 The
524 .Nm
525 format has a rich history, dating back to Sixth Edition
526 .Ux .
527 The current implementation of
528 .Nm
529 is the GNU implementation, which
530 originated as the public-domain
531 .Nm
532 written by
533 .An John Gilmore .
534 .Sh AUTHORS
535 .An -nosplit
536 A cast of thousands, including [as listed in the
537 .Pa ChangeLog
538 file in the source]
539 .An John Gilmore
540 (author of original public domain version),
541 .An Jay Fenlason
542 (first GNU author),
543 .An Joy Kendall ,
544 .An Jim Kingdon ,
545 .An David J. MacKenzie ,
546 .An Michael I Bushnell ,
547 .An Noah Friedman ,
548 and innumerable others who have contributed fixes and additions.
549 .Pp
550 Man page obtained by the
551 .Fx
552 group from the
553 .Nx 1.0
554 release.
555 .Sh BUGS
556 The
557 .Fl C
558 feature does not work like historical
559 .Nm
560 programs, and is probably untrustworthy.
561 .Pp
562 The 
563 .Fl A 
564 command should work to join an arbitrary number of
565 .Nm
566 archives
567 together, but it does not; attempting to do so leaves the
568 end-of-archive blocks in place for the second and subsequent archives.
569 .Pp
570 The
571 .Nm
572 file format is a semi fixed width field format, and the field
573 for device numbers were designed for 16 bit (8 major, 8 minor)
574 and can not absorb our 32 bit (8 major, 16+8 minor) numbers.