1 .\" $OpenBSD: tar.1,v 1.59 2015/09/13 15:42:11 guenther 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 .Dd $Mdocdate: September 13 2015 $
35 .No { Cm crtux No } Op Cm 014578befHhjLmNOoPpqsvwXZz
38 .Op Ar blocking-factor | archive | replstr
44 .No { Ns Fl crtux Ns }
46 .Op Fl 014578eHhjLmNOoPpqvwXZz
47 .Op Fl b Ar blocking-factor
57 command creates, adds files to, or extracts files from an
61 A tar archive is often stored on a magnetic tape, but can be
62 stored equally well on a floppy, CD-ROM, or in a regular disk file.
64 In the first (legacy) form, all option flags except for
68 must be contained within the first argument to
70 and must not be prefixed by a hyphen
72 Option arguments, if any, are processed as subsequent arguments to
74 and are processed in the order in which their corresponding option
75 flags have been presented on the command line.
77 In the second and preferred form, option flags may be given in any order
78 and are immediately followed by their corresponding option argument
81 One of the following flags must be present:
84 Create new archive, or overwrite an existing archive,
85 adding the specified files to it.
87 Append the named new files to existing archive.
88 Note that this will only work on media on which an end-of-file mark
91 List contents of archive.
92 If any files are named on the
93 command line, only those files will be listed.
96 arguments may be specified as glob patterns (see
98 for more information), in which case
100 will list all archive members that match each pattern.
105 Extract files from archive.
106 If any files are named on the
107 command line, only those files will be extracted from the
111 arguments may be specified as glob patterns (see
113 for more information), in which case
115 will extract all archive members that match each pattern.
117 If more than one copy of a file exists in the
118 archive, later copies will overwrite earlier copies during
120 The file mode and modification time are preserved
122 The file mode is subject to modification by the
126 In addition to the flags mentioned above, any of the following
129 .It Fl b Ar blocking-factor
130 Set blocking factor to use for the archive.
132 uses 512-byte blocks.
133 The default is 20, the maximum is 126.
134 Archives with a blocking factor larger than 63
135 violate the POSIX standard and will not be portable to all systems.
136 .It Fl C Ar directory
137 This is a positional argument which sets the working directory for the
139 When extracting, files will be extracted into
140 the specified directory; when creating, the specified files will be matched
143 Stop after the first error.
145 Filename where the archive is stored.
150 standard output is used.
153 environment variable.
155 Follow symlinks given on the command line only.
157 Follow symbolic links as if they were normal files
159 In extract mode this means that a directory entry in the archive
160 will not overwrite an existing symbolic link, but rather what the
161 link ultimately points to.
163 This is a positional argument which reads the names of files to
164 archive or extract from the given file, one per line.
166 Compress archive using bzip2.
167 The bzip2 utility must be installed separately.
173 Do not preserve modification time.
175 Use only the numeric UID and GID values when creating or extracting an
178 Write old-style (non-POSIX) archives.
180 Don't write directory information that the older (V7) style
187 Do not strip leading slashes
190 The default is to strip leading slashes.
192 Preserve user and group ID as well as file mode regardless of
195 The setuid and setgid bits are only preserved if the user and group ID
197 Only meaningful in conjunction with the
201 Select the first archive member that matches each
204 No more than one archive member is matched for each
206 When members of type directory are matched, the file hierarchy rooted at that
207 directory is also matched.
209 Modify the archive member names according to the substitution expression
211 using the syntax of the
213 utility regular expressions.
215 arguments may be given to restrict the list of archive members to those
218 The format of these regular expressions is
225 is a basic regular expression (see
229 can contain an ampersand
234 is a digit) back-references,
235 or subexpression matching.
238 string may also contain newline characters.
239 Any non-null character can be used as a delimiter
246 expressions can be specified.
247 The expressions are applied in the order they are specified on the
248 command line, terminating with the first successful substitution.
250 The optional trailing
252 continues to apply the substitution expression to the pathname substring,
253 which starts with the first character following the end of the last successful
255 The first unsuccessful substitution stops the operation of the
258 The optional trailing
260 will cause the final result of a successful substitution to be written to
261 standard error in the following format:
263 .D1 Em original-pathname No >> Em new-pathname
265 File or archive member names that substitute to the empty string
266 are not selected and will be skipped.
268 Verbose operation mode.
270 Interactively rename files.
273 to prompt the user for the filename to use when storing or
274 extracting files in an archive.
276 Do not cross mount points in the file system.
278 Compress archive using
281 Compress archive using
287 can be used to select one of the compiled-in backup devices,
292 Path in which to store temporary files.
294 Default tape device to use instead of
298 standard output is used.
301 .Bl -tag -width "/dev/rst0"
308 utility exits with one of the following values:
310 .Bl -tag -width Ds -offset indent -compact
312 All files were processed successfully.
317 Create an archive on the default tape drive, containing the files named
322 .Dl $ tar c bonvole sekve
326 compressed archive containing the files
333 .Dl $ tar zcf foriru.tar.gz bonvole sekve
335 Verbosely create an archive, called
337 of all files matching the shell
342 .Dl $ tar zcvf backup.tar.gz *.c
344 Verbosely list, but do not extract, all files ending in
346 from a compressed archive named
348 Note that the glob pattern has been quoted to avoid expansion by the shell:
350 .Dl $ tar tvzf backup.tar.gz '*.jpeg'
352 For more detailed examples, see
357 cannot create a file or a link when extracting an archive or cannot
358 find a file while writing an archive, or cannot preserve the user
359 ID, group ID, file mode, or access and modification times when the
361 option is specified, a diagnostic message is written to standard
362 error and a non-zero exit value will be returned, but processing
366 cannot create a link to a file,
368 will not create a second copy of the file.
370 If the extraction of a file from an archive is prematurely terminated
371 by a signal or error,
373 may have only partially extracted the file the user wanted.
374 Additionally, the file modes of extracted files and directories may
375 have incorrect file bits, and the modification and access times may
378 If the creation of an archive is prematurely terminated by a signal
381 may have only partially created the archive, which may violate the
382 specific archive format specification.
389 command first appeared in
393 at the University of California, San Diego.
399 flags are not portable to other versions of
401 where they may have a different meaning.