1 .\" $NetBSD: tar.1,v 1.26 2007/12/02 21:14:49 wiz Exp $
3 .\" Copyright (c) 1996 SigmaSoft, Th. Lockert
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\" OpenBSD: tar.1,v 1.28 2000/11/09 23:58:56 aaron Exp
37 .Oo \&- Oc {crtux} Op Fl 014578befHhjklmOoPpqSvwXZz
41 .\" XXX how to do this right?
49 command creates, adds files to, or extracts files from an
53 A tar archive is often stored on a magnetic tape, but can be
54 stored equally well on a floppy, CD-ROM, or in a regular disk file.
56 One of the following flags must be present:
59 Create new archive, or overwrite an existing archive,
60 adding the specified files to it.
62 Append the named new files to existing archive.
63 Note that this will only work on media on which an end-of-file mark
66 List contents of archive.
67 If any files are named on the
68 command line, only those files will be listed.
72 .It Fl x , -extract , -get
73 Extract files from archive.
74 If any files are named on the
75 command line, only those files will be extracted from the
77 If more than one copy of a file exists in the
78 archive, later copies will overwrite earlier copies during
80 The file mode and modification time are preserved
82 The file mode is subject to modification by the
86 In addition to the flags mentioned above, any of the following
89 .It Fl b Ar "blocking factor" , Fl -block-size Ar "blocking factor"
90 Set blocking factor to use for the archive.
93 The default is 20, the maximum is 126.
94 Archives with a blocking factor larger 63 violate the
96 standard and will not be portable to all systems.
98 Stop after first error.
99 .It Fl f Ar archive , Fl -file Ar archive
100 Filename where the archive is stored.
103 If the archive is of the form:
104 .Ar [[user@]host:]file
105 then the archive will be processed using
107 .It Fl h , -dereference
108 Follow symbolic links as if they were normal files
110 .It Fl j, -bzip2, -bunzip2
113 for compression of the archive.
114 This option is a GNU extension.
115 .It Fl k , -keep-old-files
116 Keep existing files; don't overwrite them from archive.
117 .It Fl l , -one-file-system
118 Do not descend across mount points.
120 .It Fl m , -modification-time
121 Do not preserve modification time.
123 When creating and appending to an archive, write old-style (non-POSIX) archives.
124 When extracting from an archive, extract to standard output.
125 .It Fl o , -portability , -old-archive
126 Don't write directory information that the older (V7) style
132 .It Fl p , -preserve-permissions , -preserve
133 Preserve user and group ID as well as file mode regardless of
136 The setuid and setgid bits are only preserved if the user is
138 Only meaningful in conjunction with the
141 .It Fl q , -fast-read
142 Select the first archive member that matches each
145 No more than one archive member is matched for each
147 When members of type directory are matched, the file hierarchy rooted at that
148 directory is also matched.
150 This flag has no effect as
152 always generates sparse files.
154 Modify the file or archive member names specified by the
158 operands according to the substitution expression
160 using the syntax of the
162 utility regular expressions.
163 The format of these regular expressions are:
168 is a basic regular expression and
170 can contain an ampersand (\*[Am]), \\n (where n is a digit) back-references,
171 or subexpression matching.
174 string may also contain
177 Any non-null character can be used as a delimiter (/ is shown here).
180 expressions can be specified.
181 The expressions are applied in the order they are specified on the
182 command line, terminating with the first successful substitution.
183 The optional trailing
185 continues to apply the substitution expression to the pathname substring
186 which starts with the first character following the end of the last successful
188 The first unsuccessful substitution stops the operation of the
191 The optional trailing
193 will cause the final result of a successful substitution to be written to
195 in the following format:
196 .Dl \*[Lt]original pathname\*[Gt] \*[Gt]\*[Gt] \*[Lt]new pathname\*[Gt]
197 File or archive member names that substitute to the empty string
198 are not selected and will be skipped.
199 The substitutions are applied by default to the destination hard and symbolic
201 The optional trailing
203 prevents the substitutions from being performed on symbolic link destinations.
205 Verbose operation mode.
206 .It Fl w , -interactive , -confirmation
207 Interactively rename files.
210 to prompt the user for the filename to use when storing or
211 extracting files in an archive.
212 .It Fl z , -gzip , -gunzip
213 Compress archive using gzip.
214 .It Fl B , -read-full-blocks
215 Reassemble small reads into full blocks (For reading from 4.2BSD pipes).
216 .It Fl C Ar directory , Fl -directory Ar directory
217 This is a positional argument which sets the working directory for the
219 When extracting, files will be extracted into
220 the specified directory; when creating, the specified files will be matched
222 This argument and its parameter may also appear in a file list specified by
225 Only follow symlinks given on command line.
227 Note SysVr3/i386 picked up ISC/SCO UNIX compatibility which implemented
229 which was defined as obtaining a list of command line switches and files
230 on which to operate from the specified file,
235 to mean something else.
236 We might someday provide SunOS-5 compatibility
237 but it makes little sense to confuse things with ISC/SCO compatibility.
239 .\"Do not follow any symlinks (do the opposite of
241 .It Fl P , -absolute-paths
242 Do not strip leading slashes
245 The default is to strip leading slashes.
246 .It Fl T Ar file , Fl -files-from Ar file
247 Read the names of files to archive or extract from the given file, one
249 A line may also specify the positional argument
250 .Dq Fl C Ar directory .
251 .It Fl X Ar file , Fl -exclude-from Ar file
252 Exclude files listed in the given file.
253 .\" exclude should be '-E' and '-X' should be one-file-system
255 Note that it would be more standard to use this option to mean ``do not
256 cross filesystem mount points.''
257 .It Fl Z , -compress , -uncompress
258 Compress archive using compress.
260 Do not enable GNU tar extensions such as long filenames and long link names.
261 .It Fl -atime-preserve
262 Preserve file access times.
265 to the current directory before extracting files.
270 to make absolute symlinks relative to the current directory.
272 Ignored, only accepted for compatibility with other
276 always unlinks files before creating them.
277 .It Fl -use-compress-program Ar program
278 Use the named program as the program to decompress the input.
280 Do not interpret filenames that contain a
286 ignores filenames that contain
289 With this option, files that contain
293 Cause files of type directory being copied or archived, or archive members of
294 type directory being extracted, to match only the directory file or archive
295 member and not the file hierarchy rooted at the directory.
300 can be used to select one of the compiled-in backup devices,
303 .Bl -tag -width "/dev/rst0"
309 will exit with one of the following values:
312 All files were processed successfully.
319 cannot create a file or a link when extracting an archive or cannot
320 find a file while writing an archive, or cannot preserve the user
321 ID, group ID, file mode, or access and modification times when the
323 option is specified, a diagnostic message is written to standard
324 error and a non-zero exit value will be returned, but processing
328 cannot create a link to a file,
330 will not create a second copy of the file.
332 If the extraction of a file from an archive is prematurely terminated
333 by a signal or error,
335 may have only partially extracted the file the user wanted.
336 Additionally, the file modes of extracted files and directories may
337 have incorrect file bits, and the modification and access times may
340 If the creation of an archive is prematurely terminated by a signal
343 may have only partially created the archive which may violate the
344 specific archive format specification.
351 command first appeared in
354 Keith Muller at the University of California, San Diego.