1 .\" $NetBSD: tar.1,v 1.35 2015/04/11 16:22:07 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 014578befHhJjklmOoPpqSvwXZz
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:
58 .It Fl c , Fl Fl create
59 Create new archive, or overwrite an existing archive,
60 adding the specified files to it.
61 .It Fl r , Fl Fl append
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.
69 .It Fl u , Fl Fl update
72 .It Fl x , Fl Fl extract , Fl Fl 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 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 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 , Fl Fl dereference
108 Follow symbolic links as if they were normal files
111 Compress/decompress archive using
113 .It Fl j, Fl Fl bzip2, Fl Fl bunzip2
116 for compression of the archive.
117 This option is a GNU extension.
118 .It Fl k , Fl Fl keep-old-files
119 Keep existing files; don't overwrite them from archive.
120 .It Fl l , Fl Fl one-file-system
121 Do not descend across mount points.
123 .It Fl m , Fl Fl modification-time
124 Do not preserve modification time.
126 When creating and appending to an archive, write old-style (non-POSIX) archives.
127 When extracting from an archive, extract to standard output.
128 .It Fl o , Fl Fl portability , Fl Fl old-archive
129 Don't write directory information that the older (V7) style
135 .It Fl p , Fl Fl preserve-permissions , Fl Fl preserve
136 Preserve user and group ID as well as file mode regardless of
139 The setuid and setgid bits are only preserved if the user is
141 Only meaningful in conjunction with the
144 .It Fl q , Fl Fl fast-read
145 Select the first archive member that matches each
148 No more than one archive member is matched for each
150 When members of type directory are matched, the file hierarchy rooted at that
151 directory is also matched.
152 .It Fl S , Fl Fl sparse
153 This flag has no effect as
155 always generates sparse files.
157 Modify the file or archive member names specified by the
161 operands according to the substitution expression
163 using the syntax of the
165 utility regular expressions.
166 The format of these regular expressions are:
171 is a basic regular expression and
173 can contain an ampersand (\*[Am]), \en (where n is a digit) back-references,
174 or subexpression matching.
177 string may also contain
180 Any non-null character can be used as a delimiter (/ is shown here).
183 expressions can be specified.
184 The expressions are applied in the order they are specified on the
185 command line, terminating with the first successful substitution.
186 The optional trailing
188 continues to apply the substitution expression to the pathname substring
189 which starts with the first character following the end of the last successful
191 The first unsuccessful substitution stops the operation of the
194 The optional trailing
196 will cause the final result of a successful substitution to be written to
198 in the following format:
199 .Dl \*[Lt]original pathname\*[Gt] \*[Gt]\*[Gt] \*[Lt]new pathname\*[Gt]
200 File or archive member names that substitute to the empty string
201 are not selected and will be skipped.
202 The substitutions are applied by default to the destination hard and symbolic
204 The optional trailing
206 prevents the substitutions from being performed on symbolic link destinations.
208 Verbose operation mode.
209 .It Fl w , Fl Fl interactive , Fl Fl confirmation
210 Interactively rename files.
213 to prompt the user for the filename to use when storing or
214 extracting files in an archive.
215 .It Fl z , Fl Fl gzip , Fl Fl gunzip
216 Compress/decompress archive using
218 .It Fl B , Fl Fl read-full-blocks
219 Reassemble small reads into full blocks (For reading from 4.2BSD pipes).
220 .It Fl C Ar directory , Fl Fl directory Ar directory
221 This is a positional argument which sets the working directory for the
223 When extracting, files will be extracted into
224 the specified directory; when creating, the specified files will be matched
226 This argument and its parameter may also appear in a file list specified by
229 Only follow symlinks given on command line.
231 Note SysVr3/i386 picked up ISC/SCO UNIX compatibility which implemented
233 which was defined as obtaining a list of command line switches and files
234 on which to operate from the specified file,
239 to mean something else.
240 We might someday provide SunOS-5 compatibility
241 but it makes little sense to confuse things with ISC/SCO compatibility.
243 .\"Do not follow any symlinks (do the opposite of
245 .It Fl P , Fl Fl absolute-paths
246 Do not strip leading slashes
249 The default is to strip leading slashes.
250 .It Fl T Ar file , Fl Fl files-from Ar file
251 Read the names of files to archive or extract from the given file, one
253 A line may also specify the positional argument
254 .Dq Fl C Ar directory .
255 .It Fl X Ar file , Fl Fl exclude-from Ar file
256 Exclude files matching the shell glob patterns listed in the given file.
257 .\" exclude should be '-E' and '-X' should be one-file-system
259 Note that it would be more standard to use this option to mean ``do not
260 cross filesystem mount points.''
261 .It Fl Z , Fl Fl compress , Fl Fl uncompress
262 Compress archive using compress.
264 Do not enable GNU tar extensions such as long filenames and long link names.
265 .It Fl Fl atime-preserve
266 Preserve file access times.
269 to the current directory before extracting files.
274 to make absolute symlinks relative to the current directory.
276 Ignored, only accepted for compatibility with other
280 always unlinks files before creating them.
281 .It Fl Fl use-compress-program Ar program
282 Use the named program as the program to decompress the input.
283 .It Fl Fl force-local
284 Do not interpret filenames that contain a
290 ignores filenames that contain
293 With this option, files that contain
296 .It Fl Fl no-recursion
297 Cause files of type directory being copied or archived, or archive members of
298 type directory being extracted, to match only the directory file or archive
299 member and not the file hierarchy rooted at the directory.
304 can be used to select one of the compiled-in backup devices,
307 .Bl -tag -width "/dev/rst0"
313 will exit with one of the following values:
316 All files were processed successfully.
323 cannot create a file or a link when extracting an archive or cannot
324 find a file while writing an archive, or cannot preserve the user
325 ID, group ID, file mode, or access and modification times when the
327 option is specified, a diagnostic message is written to standard
328 error and a non-zero exit value will be returned, but processing
332 cannot create a link to a file,
334 will not create a second copy of the file.
336 If the extraction of a file from an archive is prematurely terminated
337 by a signal or error,
339 may have only partially extracted the file the user wanted.
340 Additionally, the file modes of extracted files and directories may
341 have incorrect file bits, and the modification and access times may
344 If the creation of an archive is prematurely terminated by a signal
347 may have only partially created the archive which may violate the
348 specific archive format specification.
355 command first appeared in
359 at the University of California, San Diego.