2001-05-08 06:19:06 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1996 SigmaSoft, Th. Lockert
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by SigmaSoft, Th. Lockert.
|
|
|
|
.\" 4. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\" $OpenBSD: tar.1,v 1.33 2001/05/01 17:58:01 aaron Exp $
|
|
|
|
.\"
|
|
|
|
.Dd February 7, 2001
|
|
|
|
.Dt TAR 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm tar
|
|
|
|
.Nd tape archiver
|
|
|
|
.Sh SYNOPSIS
|
2001-05-08 08:12:53 +00:00
|
|
|
.Nm
|
2001-05-08 06:19:06 +00:00
|
|
|
.Sm off
|
2001-05-08 08:12:53 +00:00
|
|
|
.Op Fl
|
|
|
|
.Brq Cm crtux
|
2003-05-01 02:37:46 +00:00
|
|
|
.Op Cm befhjmopqsvwyzHLOPXZ014578
|
2001-05-08 06:19:06 +00:00
|
|
|
.Sm on
|
|
|
|
.Op Ar blocksize
|
|
|
|
.Op Ar archive
|
|
|
|
.Op Ar replstr
|
|
|
|
.\" XXX how to do this right?
|
|
|
|
.Op Fl C Ar directory
|
|
|
|
.Op Fl I Ar file
|
2001-05-08 08:12:53 +00:00
|
|
|
.Op Ar
|
2001-05-08 06:19:06 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command creates, adds files to, or extracts files from an
|
|
|
|
archive file in
|
2001-05-08 08:12:53 +00:00
|
|
|
.Nm
|
2001-05-08 06:19:06 +00:00
|
|
|
format.
|
2001-05-08 08:12:53 +00:00
|
|
|
A
|
|
|
|
.Nm
|
|
|
|
archive is often stored on a magnetic tape, but can be
|
2001-05-08 06:19:06 +00:00
|
|
|
stored equally well on a floppy, CD-ROM, or in a regular disk file.
|
|
|
|
.Pp
|
|
|
|
One of the following flags must be present:
|
2001-05-08 08:12:53 +00:00
|
|
|
.Bl -tag -width indent
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl c
|
|
|
|
Create new archive, or overwrite an existing archive,
|
|
|
|
adding the specified files to it.
|
|
|
|
.It Fl r
|
|
|
|
Append the named new files to existing archive.
|
|
|
|
Note that this will only work on media on which an end-of-file mark
|
|
|
|
can be overwritten.
|
|
|
|
.It Fl t
|
|
|
|
List contents of archive.
|
|
|
|
If any files are named on the
|
|
|
|
command line, only those files will be listed.
|
|
|
|
.It Fl u
|
|
|
|
Alias for
|
|
|
|
.Fl r .
|
|
|
|
.It Fl x
|
|
|
|
Extract files from archive.
|
|
|
|
If any files are named on the
|
|
|
|
command line, only those files will be extracted from the
|
|
|
|
archive.
|
|
|
|
If more than one copy of a file exists in the
|
|
|
|
archive, later copies will overwrite earlier copies during
|
|
|
|
extraction.
|
|
|
|
The file mode and modification time are preserved
|
|
|
|
if possible.
|
|
|
|
The file mode is subject to modification by the
|
|
|
|
.Xr umask 2 .
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
In addition to the flags mentioned above, any of the following
|
|
|
|
flags may be used:
|
2001-05-08 08:12:53 +00:00
|
|
|
.Bl -tag -width indent
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl b Ar "blocking factor"
|
2002-04-20 11:58:12 +00:00
|
|
|
Set blocking factor to use for the archive, with 512 byte blocks.
|
2001-05-08 06:19:06 +00:00
|
|
|
The default is 20, the maximum is 126.
|
|
|
|
Archives with a blocking factor larger 63 violate the
|
|
|
|
.Tn POSIX
|
|
|
|
standard and will not be portable to all systems.
|
|
|
|
.It Fl e
|
|
|
|
Stop after first error.
|
|
|
|
.It Fl f Ar archive
|
|
|
|
Filename where the archive is stored.
|
|
|
|
Defaults to
|
2002-10-06 07:56:27 +00:00
|
|
|
.Pa /dev/sa0 .
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl h
|
|
|
|
Follow symbolic links as if they were normal files
|
|
|
|
or directories.
|
|
|
|
.It Fl j
|
2001-05-08 08:12:53 +00:00
|
|
|
Compress archives using
|
|
|
|
.Xr bzip2 1 .
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl m
|
|
|
|
Do not preserve modification time.
|
|
|
|
.It Fl O
|
2001-05-08 08:12:53 +00:00
|
|
|
Write old-style
|
|
|
|
.Pq non- Ns Tn POSIX
|
|
|
|
archives.
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl o
|
|
|
|
Don't write directory information that the older (V7) style
|
|
|
|
.Nm
|
|
|
|
is unable to decode.
|
|
|
|
This implies the
|
|
|
|
.Fl O
|
|
|
|
flag.
|
|
|
|
.It Fl p
|
|
|
|
Preserve user and group ID as well as file mode regardless of
|
|
|
|
the current
|
|
|
|
.Xr umask 2 .
|
|
|
|
The setuid and setgid bits are only preserved if the user is
|
|
|
|
the superuser.
|
|
|
|
Only meaningful in conjunction with the
|
|
|
|
.Fl x
|
|
|
|
flag.
|
|
|
|
.It Fl q
|
|
|
|
Select the first archive member that matches each
|
|
|
|
.Ar pattern
|
|
|
|
operand.
|
|
|
|
No more than one archive member is matched for each
|
|
|
|
.Ar pattern .
|
|
|
|
When members of type directory are matched, the file hierarchy rooted at that
|
|
|
|
directory is also matched.
|
|
|
|
.It Fl s Ar replstr
|
|
|
|
Modify the file or archive member names specified by the
|
|
|
|
.Ar pattern
|
|
|
|
or
|
|
|
|
.Ar file
|
|
|
|
operands according to the substitution expression
|
|
|
|
.Ar replstr ,
|
|
|
|
using the syntax of the
|
|
|
|
.Xr ed 1
|
|
|
|
utility regular expressions.
|
|
|
|
The format of these regular expressions are:
|
|
|
|
.Dl /old/new/[gp]
|
|
|
|
As in
|
|
|
|
.Xr ed 1 ,
|
|
|
|
.Cm old
|
|
|
|
is a basic regular expression and
|
|
|
|
.Cm new
|
2001-05-08 08:12:53 +00:00
|
|
|
can contain an ampersand
|
|
|
|
.Pq Ql & ,
|
|
|
|
.Li \e Ns Ar n
|
|
|
|
(where
|
|
|
|
.Ar n
|
|
|
|
is a digit) back-references,
|
2001-05-08 06:19:06 +00:00
|
|
|
or subexpression matching.
|
|
|
|
The
|
|
|
|
.Cm old
|
2001-05-08 08:12:53 +00:00
|
|
|
string may also contain newline characters.
|
|
|
|
Any non-null character can be used as a delimiter
|
|
|
|
.Ql ( /
|
|
|
|
is shown here).
|
2001-05-08 06:19:06 +00:00
|
|
|
Multiple
|
|
|
|
.Fl s
|
|
|
|
expressions can be specified.
|
|
|
|
The expressions are applied in the order they are specified on the
|
|
|
|
command line, terminating with the first successful substitution.
|
|
|
|
The optional trailing
|
|
|
|
.Cm g
|
|
|
|
continues to apply the substitution expression to the pathname substring
|
|
|
|
which starts with the first character following the end of the last successful
|
|
|
|
substitution.
|
|
|
|
The first unsuccessful substitution stops the operation of the
|
|
|
|
.Cm g
|
|
|
|
option.
|
|
|
|
The optional trailing
|
|
|
|
.Cm p
|
|
|
|
will cause the final result of a successful substitution to be written to
|
2001-05-08 08:12:53 +00:00
|
|
|
standard error
|
2001-05-08 06:19:06 +00:00
|
|
|
in the following format:
|
2001-05-08 08:12:53 +00:00
|
|
|
.Pp
|
2001-05-08 06:19:06 +00:00
|
|
|
.Dl <original pathname> >> <new pathname>
|
2001-05-08 08:12:53 +00:00
|
|
|
.Pp
|
2001-05-08 06:19:06 +00:00
|
|
|
File or archive member names that substitute to the empty string
|
|
|
|
are not selected and will be skipped.
|
|
|
|
.It Fl v
|
|
|
|
Verbose operation mode.
|
|
|
|
.It Fl w
|
|
|
|
Interactively rename files.
|
|
|
|
This option causes
|
|
|
|
.Nm
|
|
|
|
to prompt the user for the filename to use when storing or
|
|
|
|
extracting files in an archive.
|
|
|
|
.It Fl y
|
2001-05-08 08:12:53 +00:00
|
|
|
Compress archives using
|
|
|
|
.Xr bzip2 1 .
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl z
|
2001-05-08 08:12:53 +00:00
|
|
|
Compress archive using
|
|
|
|
.Xr gzip 1 .
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl C Ar directory
|
|
|
|
This is a positional argument which sets the working directory for the
|
|
|
|
following files.
|
|
|
|
When extracting, files will be extracted into
|
|
|
|
the specified directory; when creating, the specified files will be matched
|
|
|
|
from the directory.
|
|
|
|
.It Fl H
|
|
|
|
Follow symlinks given on command line only.
|
|
|
|
.It Fl L
|
|
|
|
Follow all symlinks.
|
|
|
|
.It Fl P
|
|
|
|
Do not strip leading slashes
|
2001-05-08 08:12:53 +00:00
|
|
|
.Pq Ql /
|
2001-05-08 06:19:06 +00:00
|
|
|
from pathnames.
|
|
|
|
The default is to strip leading slashes.
|
|
|
|
.It Fl I Ar file
|
|
|
|
This is a positional argument which reads the names of files to
|
|
|
|
archive or extract from the given file, one per line.
|
|
|
|
.It Fl X
|
2002-08-21 17:32:44 +00:00
|
|
|
Do not cross mount points in the file system.
|
2001-05-08 06:19:06 +00:00
|
|
|
.It Fl Z
|
2001-05-08 08:12:53 +00:00
|
|
|
Compress archive using
|
|
|
|
.Xr compress 1 .
|
2001-05-08 06:19:06 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The options
|
|
|
|
.Op Fl 014578
|
|
|
|
can be used to select one of the compiled-in backup devices,
|
2001-05-08 08:12:53 +00:00
|
|
|
.Pa /dev/rst Ns Ar N .
|
|
|
|
.Sh ENVIRONMENT
|
|
|
|
.Bl -tag -width TMPDIR
|
|
|
|
.It Ev TMPDIR
|
|
|
|
Path in which to store temporary files.
|
|
|
|
.It Ev TAPE
|
|
|
|
Default tape device to use instead of
|
2002-10-06 07:56:27 +00:00
|
|
|
.Pa /dev/sa0 .
|
2001-05-08 08:12:53 +00:00
|
|
|
.El
|
|
|
|
.Sh FILES
|
2002-10-06 07:56:27 +00:00
|
|
|
.Bl -tag -width "/dev/sa0"
|
|
|
|
.It Pa /dev/sa0
|
2001-05-08 08:12:53 +00:00
|
|
|
default archive name
|
|
|
|
.El
|
2001-05-08 06:19:06 +00:00
|
|
|
.Sh DIAGNOSTICS
|
2002-04-20 11:58:12 +00:00
|
|
|
The
|
2001-05-08 06:19:06 +00:00
|
|
|
.Nm
|
2002-04-20 11:58:12 +00:00
|
|
|
utility will exit with one of the following values:
|
2001-05-08 06:19:06 +00:00
|
|
|
.Bl -tag -width 2n
|
|
|
|
.It 0
|
|
|
|
All files were processed successfully.
|
|
|
|
.It 1
|
|
|
|
An error occurred.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Whenever
|
|
|
|
.Nm
|
|
|
|
cannot create a file or a link when extracting an archive or cannot
|
|
|
|
find a file while writing an archive, or cannot preserve the user
|
|
|
|
ID, group ID, file mode, or access and modification times when the
|
|
|
|
.Fl p
|
|
|
|
option is specified, a diagnostic message is written to standard
|
|
|
|
error and a non-zero exit value will be returned, but processing
|
|
|
|
will continue.
|
|
|
|
In the case where
|
|
|
|
.Nm
|
|
|
|
cannot create a link to a file,
|
|
|
|
.Nm
|
|
|
|
will not create a second copy of the file.
|
|
|
|
.Pp
|
|
|
|
If the extraction of a file from an archive is prematurely terminated
|
|
|
|
by a signal or error,
|
|
|
|
.Nm
|
|
|
|
may have only partially extracted the file the user wanted.
|
|
|
|
Additionally, the file modes of extracted files and directories may
|
|
|
|
have incorrect file bits, and the modification and access times may
|
|
|
|
be wrong.
|
|
|
|
.Pp
|
|
|
|
If the creation of an archive is prematurely terminated by a signal
|
|
|
|
or error,
|
|
|
|
.Nm
|
|
|
|
may have only partially created the archive which may violate the
|
|
|
|
specific archive format specification.
|
2001-05-08 08:12:53 +00:00
|
|
|
.Sh COMPATIBILITY
|
|
|
|
The
|
|
|
|
.Fl L
|
|
|
|
flag is not portable to other versions of
|
|
|
|
.Nm
|
|
|
|
where it may have a different meaning.
|
2001-05-08 06:19:06 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr cpio 1 ,
|
|
|
|
.Xr pax 1
|
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm
|
|
|
|
command first appeared in
|
|
|
|
.At v7 .
|
2001-05-08 08:12:53 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An Keith Muller
|
|
|
|
at the University of California, San Diego.
|