Merge from vendor branch TNF:
[pkgsrcv2.git] / archivers / gtar-base / files / gtar.1
1 .\" Copyright (c) 1991, 1992, 1993 Free Software Foundation     -*- nroff -*-
2 .\" See section COPYING for conditions for redistribution
3 .\"
4 .\"     Written by John F. Woods <jfw@jfwhome.funhouse.com>
5 .\"
6 .\"     $NetBSD$
7 .\"     from NetBSD: tar.1,v 1.8 1997/06/06 07:59:54 jeremy Exp
8 .\"
9 .Dd 6 August 1994
10 .Os NetBSD
11 .Dt GTAR 1
12 .Sh NAME
13 .Nm gtar
14 .Nd GNU tape archiver; manipulate "tar" archive files
15 .Sh SYNOPSIS
16 .Nm
17 .Op Cm Bq -
18 .Op Cm bundled-options
19 .Op Ar [gnu-style-flags]
20 .Op Ar tarfile
21 .Op Ar blocksize
22 .Op Ar exclude-file
23 .Op Ar filenames
24 .Op Fl C Ar directory-name
25 .Sh DESCRIPTION
26 .Nm
27 is short for 
28 .Dq tape archiver,
29 so named for historical reasons; the
30 .Nm
31 program creates, adds files to, or extracts files from an archive file
32 in
33 .Dq tar
34 format, called a
35 .Ar tarfile .
36 A tarfile is often a magnetic tape, but can be a floppy diskette or any
37 regular disk file.
38 .Pp
39 The first argument word of the
40 .Nm
41 command line is usually a command word of bundled function and modifier
42 letters, optionally preceeded by a dash;
43 it must contain exactly one function letter from the set
44 .Cm A ,
45 .Cm c ,
46 .Cm d ,
47 .Cm r ,
48 .Cm t ,
49 .Cm u ,
50 .Cm x ,
51 for append, create, difference, replace, table of contents, update, and
52 extract (further described below).  The command word can also contain other
53 function modifiers described below, some of which will take arguments from
54 the command line in the order they are specified in the command word (review
55 the EXAMPLES section).  Functions and function modifiers can also be specified
56 with the GNU argument convention (preceeded by two dashes, one function or
57 modifier per word.  Command-line arguments that specify files to
58 add to, extract from, or list from an archive may be given as shell
59 pattern matching strings.
60 .Sh FUNCTIONS
61 Exactly one of the following functions must be specified.
62 .Pp
63 .Bl -tag -width "--concatenate" -compact
64 .It Fl A
65 .It Fl -catenate
66 .It Fl "-concatenate"
67 Append the contents of named file, which must itself be a tar archive,
68 to the end of the archive (erasing the old end-of-archive block).
69 This has the effect of adding the files contained in the named file to
70 the first archive, rather than adding the second archive as an element
71 of the first.
72 .Em Note:
73 This option requires a rewritable tarfile,
74 and therefore does not work on quarter-inch cartridge tapes.
75 .It Fl c
76 .It Fl -create
77 Create a new archive (or truncates an old one) and writes the named files
78 to it.
79 .It Fl d
80 .It Fl -diff
81 .It Fl -compare
82 Find differences between files in the archive and corresponding files in
83 the file system.
84 .It Fl -delete
85 Delete named files from the archive (Does not work on quarter-inch tapes).
86 .It Fl r
87 .It Fl -append
88 Append files to the end of an archive (Does not work on quarter-inch tapes).
89 .It Fl t
90 .It Fl -list
91 List the contents of an archive; if filename arguments are given, only those
92 files are listed, otherwise the entire table of contents is listed.
93 .It Fl u
94 .It Fl -update
95 Append the named files if the on-disk version has a modification date
96 more recent than their copy in the archive (if any).  Does not work on
97 quarter-inch tapes.
98 .It Fl x
99 .It Fl -extract
100 .It Fl -get
101 Extract files from an archive.  The owner, modification time, and file
102 permissions are restored, if possible.  If no
103 .Ar file
104 arguments are given, extract all the files in the archive.  If a
105 .Ar filename
106 argument matches the name of a directory on the tape, that directory and
107 its contents are extracted (as well as all directories under that directory).
108 If the archive contains multiple entries corresponding to the same file
109 (see the
110 .Fl -append
111 command above), the last one extracted will overwrite all earlier versions.
112 .El
113 .Sh OPTIONS
114 The other options to
115 .Nm
116 may be combined arbitrarily; single-letter options may be bundled in with
117 the command word.  Verbose options which take arguments will be
118 followed by the argument; single-letter options will consume
119 successive command line arguments (see the
120 .Sx EXAMPLES
121 below).
122 .Pp
123 .Bl -tag -width "--preserve-permissions" -compact
124 .It Fl -help
125 Prints a message listing and briefly describing all the command
126 options to tar.
127 .It Fl -atime-preserve
128 Restore the access times on files which are written to tape (note that
129 this will change the inode-change time!).
130 .It Fl b
131 .It Fl -block-size Ar number
132 Sets the block size for reading or writing to N 512-byte blocks.
133 .It Fl B
134 .It Fl -read-full-blocks
135 Re-assemble short reads into full blocks (for reading 4.2BSD pipes).
136 .It Fl C Ar directory
137 .It Fl -directory Ar directory
138 Change to
139 .Ar directory
140 for extraction.
141 .It Fl -checkpoint
142 Print directory names while reading the archive.
143 .It Fl f Ar [hostname:]file
144 .It Fl -file  Ar [hostname:]file
145 Read or write the specified
146 .Ar file
147 .Po default is Pa /dev/rst0 Pc .
148 If a
149 .Ar hostname
150 is specified,
151 .Nm
152 will use
153 .Xr rmt 8
154 to read or write the specified
155 .Ar file
156 on a remote machine. If the given
157 .Ar file
158 is
159 .Ql - ,
160 then
161 .Nm
162 uses stdin or stdout.
163 .It Fl F Ar file
164 .It Fl -info-script Ar file
165 .It Fl -new-volume-script Ar file
166 Run a script at the end of each archive volume (implies
167 .Fl M ) .
168 .It Fl -fast-read
169 Stop after all non-wildcard extraction targets have been found
170 in the archive.
171 .It Fl G
172 .It Fl -incremental
173 Create/list/extract old GNU-format incremental backup.
174 .It Fl g Ar file
175 .It Fl -listed-incremental Ar file
176 Create/list/extract new GNU-format incremental backup.
177 .It Fl h
178 .It Fl -dereference
179 Don't write symlinks as symlinks; write the data of the files they name.
180 .It Fl i
181 .It Fl -ignore-zeros
182 Ignore blocks of zeroes in archive (usually means End-Of-File).
183 .It Fl -ignore-failed-read
184 Don't exit with non-zero status on unreadable files.
185 .It Fl k
186 .It Fl -keep-old-files
187 Keep files which already exist on disk; don't overwrite them from the archive.
188 .It Fl K Ar file
189 .It Fl -starting-file Ar file
190 Begin at
191 .Ar file
192 in the archive.
193 .It Fl l
194 .It Fl -one-file-system
195 Stay in local filesystem when creating an archive (do not cross mount
196 points).
197 .It Fl L Ar number
198 .It Fl -tape-length Ar number
199 Change tapes after writing N*1024 bytes.
200 .It Fl m
201 .It Fl -modification-time
202 Don't extract file modified time.
203 .It Fl M
204 .It Fl -multi-volume
205 Create/list/extract multi-volume archive.
206 .It Fl N Ar date
207 .It Fl -after-date Ar date
208 .It Fl -newer Ar date
209 Only store files newer than
210 .Ar date .
211 .It Fl o
212 .It Fl -old-archive
213 .It Fl -portability
214 Write a V7 format archive, rather than POSIX format.
215 .It Fl O
216 .It Fl -to-stdout
217 Extract files to standard output.
218 .It Fl p
219 .It Fl -same-permissions
220 .It Fl -preserve-permissions
221 Extract all protection information.
222 .It Fl -preserve
223 Has the effect of
224 .Fl p s.
225 .It Fl P
226 .It Fl -absolute-paths
227 Don't strip leading `/'s from file names.
228 .It Fl R
229 .It Fl -record-number
230 Show record number within archive with each message.
231 .It Fl -remove-files
232 Remove files after adding them to the archive.
233 .It Fl s
234 .It Fl -same-order
235 .It Fl -preserve-order
236 List of names to extract is sorted to match archive.
237 .It Fl S
238 .It Fl -sparse
239 Handle "sparse" files efficiently.
240 .It Fl T Ar file
241 .It Fl -files-from Ar file
242 Get names of files to extract or create from
243 .Ar file ,
244 one per line.
245 .It Fl -null
246 Modifies behavior of
247 .Fl T
248 to expect null-terminated names; disables
249 .Fl C.
250 .It Fl -totals
251 Prints total bytes written with
252 .Fl -create .
253 .It Fl v
254 .It Fl -verbose
255 Lists files written to archive with
256 .Fl -create
257 or extracted with
258 .Fl -extract ;
259 lists file protection information along with file names with
260 .Fl -list .
261 .It Fl V Ar volume-name
262 .It Fl -label Ar volume-name
263 Create archive with the given
264 .Ar volume-name .
265 .It Fl -version
266 Print tar program version number.
267 .It Fl w
268 .It Fl -interactive
269 .It Fl -confirmation
270 Ask for confirmation for every action.
271 .It Fl W
272 .It Fl -verify
273 Attempt to verify the archive after writing it.
274 .It Fl -exclude Ar pattern
275 Exclude files matching the
276 .Ar pattern
277 (don't extract them, don't add them, don't list them).
278 .It Fl X Ar file
279 .It Fl -exclude-from Ar file
280 Exclude files listed in
281 .Ar file .
282 .It Fl Z
283 .It Fl -compress
284 .It Fl -uncompress
285 Filter the archive through
286 .Xr compress 1 .
287 .It Fl z
288 .It Fl -gzip
289 .It Fl -gunzip
290 Filter the archive through
291 .Xr gzip 1 .
292 .It Fl -use-compress-program Ar program
293 Filter the archive through
294 .Ar program
295 (which must accept
296 .Fl d
297 to mean ``decompress'').
298 .It Fl -block-compress
299 Block the output of compression program for tapes or floppies
300 (otherwise writes will be of odd length, which device drivers may reject).
301 .It Fl [0-7][lmh]
302 Specify tape drive and density.
303 .It Fl -norecurse
304 Don't recurse into subdirectories when creating.
305 .It Fl -unlink
306 Unlink files before creating them.
307 .El
308 .Sh EXAMPLES
309 To create an archive on tape drive
310 .Pa /dev/rst0
311 with a block size of 20
312 blocks, containing files named "bert" and "ernie", you can enter
313 .Dl tar cfb /dev/rst0 20 bert ernie
314 or
315 .Dl tar --create --file /dev/rst0 --block-size 20 bert ernie
316 Note that the
317 .Fl f
318 and
319 .Fl b
320 flags both require arguments, which they take from the command line in
321 the order they were listed in the command word.
322 .Pp
323 Because
324 .Pa /dev/rst0
325 is the default device, and 20 is the default block
326 size, the above example could have simply been
327 .Dl tar c bert ernie
328 .Pp
329 To extract all the C sources and headers from an archive named
330 "backup.tar", type
331 .Dl tar xf backup.tar "*.[ch]"
332 Note that the pattern must be quoted to prevent the shell from
333 attempting to expand it according the files in the current working
334 directory (the shell does not have access to the list of files in
335 the archive, of course).
336 .Pp
337 To copy a file hierarchy while preserving metadata, type
338 .Dl tar cf - -C srcdir ". |" tar xpf "-C destdir"
339 .Pp
340 To create a compressed archive on diskette, using gzip, use a command-line like
341 .Dl tar --block-compress -z -c -v -f /dev/rfd1a -b 36 tar/
342 Note that you cannot mix bundled flags and --style flags; you can use
343 single-letter flags in the manner above, rather than having to type
344 .Dl tar --block-compress --gzip --verbose --file /dev/rfd1a --block-size 20 tar/
345 .Pp
346 The above-created diskette can be listed with
347 .Dl tar tvfbz /dev/rfd1a 36
348 .Pp
349 To join two tar archives into a single archive, use
350 .Dl tar Af archive1.tar archive2.tar
351 which will add the files contained in archive2.tar onto the end of
352 archive1.tar (note that this can't be done by simply typing
353 .Dl cat archive2.tar >> archive1.tar
354 because of the end-of-file block at the end of a tar archive).
355 .Sh ENVIRONMENT
356 The
357 .Nm
358 program examines the following environment variables:
359 .Bl -tag -width "POSIXLY-CORRECT"
360 .It Ev POSIXLY-CORRECT
361 Normally, 
362 .Nm
363 will process flag arguments that appear in the file list.
364 If set in the environment, this flag causes
365 .Nm
366 to consider the first
367 non-flag argument to terminate flag processing, as per the POSIX specification.
368 .It Ev SHELL
369 In interactive mode, a permissible response to the prompt is to
370 request to spawn a subshell, which will be "/bin/sh" unless the
371 .Ev SHELL
372 variable is set.
373 .It Ev TAPE
374 Changes the default tape drive (which is still overridden by the
375 .Fl f
376 flag).
377 .El
378 .Sh FILES
379 .Bl -tag -width "/dev/rst0"
380 .It Pa /dev/rst0
381 The default tape drive.
382 .El
383 .\" This next request is for sections 1, 6, 7 & 8 only
384 .\"     (command return values (to shell) and fprintf/stderr type diagnostics)
385 .\" .Sh DIAGNOSTICS
386 .Sh SEE ALSO
387 .Xr compress 1 ,
388 .Xr gzip 1 ,
389 .Xr pax 1 ,
390 .Xr rmt 8
391 .\" .Sh STANDARDS
392 .Sh HISTORY
393 The tar format has a rich history, dating back to Sixth Edition UNIX.
394 The current implementation of tar is the GNU implementation, which
395 originated as the public-domain tar written by John Gilmore.
396 .Sh AUTHORS
397 A cast of thousands, including [as listed in the ChangeLog file in the
398 source] John Gilmore (author of original public
399 domain version), Jay Fenlason (first GNU author), Joy Kendall, Jim
400 Kingdon, David J. MacKenzie, Michael I Bushnell, Noah Friedman, and
401 innumerable others who have contributed fixes and additions.
402 .Sh BUGS
403 The
404 .Fl C
405 feature does not work like historical tar programs, and is probably
406 untrustworthy.
407 .Pp
408 The
409 .Fl A
410 command should work to join an arbitrary number of tar archives
411 together, but it does not; attempting to do so leaves the
412 end-of-archive blocks in place for the second and subsequent archives.