2012-10-22 16:10:38 +02:00
|
|
|
.\" $NetBSD: tar.1,v 1.33 2012/03/22 07:58:17 wiz Exp $
|
|
|
|
.\"
|
2010-02-24 12:58:10 +01: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.
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
2012-10-22 16:10:38 +02:00
|
|
|
.\" OpenBSD: tar.1,v 1.28 2000/11/09 23:58:56 aaron Exp
|
2010-02-24 12:58:10 +01:00
|
|
|
.\"
|
2012-10-22 16:10:38 +02:00
|
|
|
.Dd June 18, 2011
|
2010-02-24 12:58:10 +01:00
|
|
|
.Dt TAR 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm tar
|
|
|
|
.Nd tape archiver
|
|
|
|
.Sh SYNOPSIS
|
2012-10-22 16:10:38 +02:00
|
|
|
.Nm tar
|
2010-02-24 12:58:10 +01:00
|
|
|
.Sm off
|
2012-10-22 16:10:38 +02:00
|
|
|
.Oo \&- Oc {crtux} Op Fl 014578befHhjklmOoPpqSvwXZz
|
2010-02-24 12:58:10 +01:00
|
|
|
.Sm on
|
|
|
|
.Op Ar archive
|
2012-10-22 16:10:38 +02:00
|
|
|
.Op Ar blocksize
|
2010-02-24 12:58:10 +01:00
|
|
|
.\" XXX how to do this right?
|
|
|
|
.Op Fl C Ar directory
|
2012-10-22 16:10:38 +02:00
|
|
|
.Op Fl s Ar replstr
|
|
|
|
.Op Fl T Ar file
|
|
|
|
.Op Ar file ...
|
2010-02-24 12:58:10 +01:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command creates, adds files to, or extracts files from an
|
|
|
|
archive file in
|
2012-10-22 16:10:38 +02:00
|
|
|
.Dq tar
|
2010-02-24 12:58:10 +01:00
|
|
|
format.
|
2012-10-22 16:10:38 +02:00
|
|
|
A tar archive is often stored on a magnetic tape, but can be
|
2010-02-24 12:58:10 +01:00
|
|
|
stored equally well on a floppy, CD-ROM, or in a regular disk file.
|
|
|
|
.Pp
|
|
|
|
One of the following flags must be present:
|
2012-10-22 16:10:38 +02:00
|
|
|
.Bl -tag -width Ar
|
|
|
|
.It Fl c , Fl Fl create
|
2010-02-24 12:58:10 +01:00
|
|
|
Create new archive, or overwrite an existing archive,
|
|
|
|
adding the specified files to it.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl r , Fl Fl append
|
2010-02-24 12:58:10 +01:00
|
|
|
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.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl t , Fl Fl list
|
2010-02-24 12:58:10 +01:00
|
|
|
List contents of archive.
|
|
|
|
If any files are named on the
|
|
|
|
command line, only those files will be listed.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl u , Fl Fl update
|
2010-02-24 12:58:10 +01:00
|
|
|
Alias for
|
|
|
|
.Fl r .
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl x , Fl Fl extract , Fl Fl get
|
2010-02-24 12:58:10 +01:00
|
|
|
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:
|
2012-10-22 16:10:38 +02:00
|
|
|
.Bl -tag -width Ar
|
|
|
|
.It Fl b Ar "blocking factor" , Fl Fl block-size Ar "blocking factor"
|
|
|
|
Set blocking factor to use for the archive.
|
|
|
|
.Nm
|
|
|
|
uses 512 byte blocks.
|
2010-02-24 12:58:10 +01: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.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl f Ar archive , Fl Fl file Ar archive
|
2010-02-24 12:58:10 +01:00
|
|
|
Filename where the archive is stored.
|
|
|
|
Defaults to
|
2012-10-22 16:10:38 +02:00
|
|
|
.Pa /dev/rst0 .
|
|
|
|
If the archive is of the form:
|
|
|
|
.Ar [[user@]host:]file
|
|
|
|
then the archive will be processed using
|
|
|
|
.Xr rmt 8 .
|
|
|
|
.It Fl h , Fl Fl dereference
|
2010-02-24 12:58:10 +01:00
|
|
|
Follow symbolic links as if they were normal files
|
|
|
|
or directories.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl j, Fl Fl bzip2, Fl Fl bunzip2
|
|
|
|
Use
|
|
|
|
.Xr bzip2 1
|
|
|
|
for compression of the archive.
|
|
|
|
This option is a GNU extension.
|
|
|
|
.It Fl k , Fl Fl keep-old-files
|
|
|
|
Keep existing files; don't overwrite them from archive.
|
|
|
|
.It Fl l , Fl Fl one-file-system
|
|
|
|
Do not descend across mount points.
|
|
|
|
.\" should be '-X'
|
|
|
|
.It Fl m , Fl Fl modification-time
|
2010-02-24 12:58:10 +01:00
|
|
|
Do not preserve modification time.
|
|
|
|
.It Fl O
|
2012-10-22 16:10:38 +02:00
|
|
|
When creating and appending to an archive, write old-style (non-POSIX) archives.
|
|
|
|
When extracting from an archive, extract to standard output.
|
|
|
|
.It Fl o , Fl Fl portability , Fl Fl old-archive
|
|
|
|
Don't write directory information that the older (V7) style
|
2010-02-24 12:58:10 +01:00
|
|
|
.Nm
|
|
|
|
is unable to decode.
|
|
|
|
This implies the
|
|
|
|
.Fl O
|
|
|
|
flag.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl p , Fl Fl preserve-permissions , Fl Fl preserve
|
2010-02-24 12:58:10 +01:00
|
|
|
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.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl q , Fl Fl fast-read
|
2010-02-24 12:58:10 +01:00
|
|
|
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.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl S , Fl Fl sparse
|
|
|
|
This flag has no effect as
|
|
|
|
.Nm
|
|
|
|
always generates sparse files.
|
2010-02-24 12:58:10 +01:00
|
|
|
.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:
|
2012-10-22 16:10:38 +02:00
|
|
|
.Dl /old/new/[gps]
|
2010-02-24 12:58:10 +01:00
|
|
|
As in
|
|
|
|
.Xr ed 1 ,
|
|
|
|
.Cm old
|
|
|
|
is a basic regular expression and
|
|
|
|
.Cm new
|
2012-10-22 16:10:38 +02:00
|
|
|
can contain an ampersand (\*[Am]), \en (where n is a digit) back-references,
|
2010-02-24 12:58:10 +01:00
|
|
|
or subexpression matching.
|
|
|
|
The
|
|
|
|
.Cm old
|
2012-10-22 16:10:38 +02:00
|
|
|
string may also contain
|
|
|
|
.Aq Dv newline
|
|
|
|
characters.
|
|
|
|
Any non-null character can be used as a delimiter (/ is shown here).
|
2010-02-24 12:58:10 +01: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
|
2012-10-22 16:10:38 +02:00
|
|
|
.Dv standard error
|
2010-02-24 12:58:10 +01:00
|
|
|
in the following format:
|
2012-10-22 16:10:38 +02:00
|
|
|
.Dl \*[Lt]original pathname\*[Gt] \*[Gt]\*[Gt] \*[Lt]new pathname\*[Gt]
|
2010-02-24 12:58:10 +01:00
|
|
|
File or archive member names that substitute to the empty string
|
|
|
|
are not selected and will be skipped.
|
2012-10-22 16:10:38 +02:00
|
|
|
The substitutions are applied by default to the destination hard and symbolic
|
|
|
|
links.
|
|
|
|
The optional trailing
|
|
|
|
.Cm s
|
|
|
|
prevents the substitutions from being performed on symbolic link destinations.
|
2010-02-24 12:58:10 +01:00
|
|
|
.It Fl v
|
|
|
|
Verbose operation mode.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl w , Fl Fl interactive , Fl Fl confirmation
|
2010-02-24 12:58:10 +01:00
|
|
|
Interactively rename files.
|
|
|
|
This option causes
|
|
|
|
.Nm
|
|
|
|
to prompt the user for the filename to use when storing or
|
|
|
|
extracting files in an archive.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl Fl xz
|
|
|
|
Compress/decompress archive using
|
|
|
|
.Xr xz 1 .
|
|
|
|
.It Fl z , Fl Fl gzip , Fl Fl gunzip
|
|
|
|
Compress/decompress archive using
|
2010-02-24 12:58:10 +01:00
|
|
|
.Xr gzip 1 .
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl B , Fl Fl read-full-blocks
|
|
|
|
Reassemble small reads into full blocks (For reading from 4.2BSD pipes).
|
|
|
|
.It Fl C Ar directory , Fl Fl directory Ar directory
|
2010-02-24 12:58:10 +01:00
|
|
|
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.
|
2012-10-22 16:10:38 +02:00
|
|
|
This argument and its parameter may also appear in a file list specified by
|
|
|
|
.Fl T .
|
2010-02-24 12:58:10 +01:00
|
|
|
.It Fl H
|
2012-10-22 16:10:38 +02:00
|
|
|
Only follow symlinks given on command line.
|
|
|
|
.Pp
|
|
|
|
Note SysVr3/i386 picked up ISC/SCO UNIX compatibility which implemented
|
|
|
|
.Dq Fl F Ar file
|
|
|
|
which was defined as obtaining a list of command line switches and files
|
|
|
|
on which to operate from the specified file,
|
|
|
|
but SunOS-5 uses
|
|
|
|
.Dq Fl I Ar file
|
|
|
|
because they use
|
|
|
|
.Sq Fl F
|
|
|
|
to mean something else.
|
|
|
|
We might someday provide SunOS-5 compatibility
|
|
|
|
but it makes little sense to confuse things with ISC/SCO compatibility.
|
|
|
|
.\".It Fl L
|
|
|
|
.\"Do not follow any symlinks (do the opposite of
|
|
|
|
.\".Fl h ).
|
|
|
|
.It Fl P , Fl Fl absolute-paths
|
2010-02-24 12:58:10 +01:00
|
|
|
Do not strip leading slashes
|
2012-10-22 16:10:38 +02:00
|
|
|
.Pq Sq /
|
2010-02-24 12:58:10 +01:00
|
|
|
from pathnames.
|
|
|
|
The default is to strip leading slashes.
|
2012-10-22 16:10:38 +02:00
|
|
|
.It Fl T Ar file , Fl Fl files-from Ar file
|
|
|
|
Read the names of files to archive or extract from the given file, one
|
|
|
|
per line.
|
|
|
|
A line may also specify the positional argument
|
|
|
|
.Dq Fl C Ar directory .
|
|
|
|
.It Fl X Ar file , Fl Fl exclude-from Ar file
|
|
|
|
Exclude files matching the shell glob patterns listed in the given file.
|
|
|
|
.\" exclude should be '-E' and '-X' should be one-file-system
|
|
|
|
.Pp
|
|
|
|
Note that it would be more standard to use this option to mean ``do not
|
|
|
|
cross filesystem mount points.''
|
|
|
|
.It Fl Z , Fl Fl compress , Fl Fl uncompress
|
|
|
|
Compress archive using compress.
|
|
|
|
.It Fl Fl strict
|
|
|
|
Do not enable GNU tar extensions such as long filenames and long link names.
|
|
|
|
.It Fl Fl atime-preserve
|
|
|
|
Preserve file access times.
|
|
|
|
.It Fl Fl chroot
|
|
|
|
.Fn chroot
|
|
|
|
to the current directory before extracting files.
|
|
|
|
Use with
|
|
|
|
.Fl x
|
|
|
|
and
|
|
|
|
.Fl h
|
|
|
|
to make absolute symlinks relative to the current directory.
|
|
|
|
.It Fl Fl unlink
|
|
|
|
Ignored, only accepted for compatibility with other
|
|
|
|
.Nm
|
|
|
|
implementations.
|
|
|
|
.Nm
|
|
|
|
always unlinks files before creating them.
|
|
|
|
.It Fl Fl use-compress-program Ar program
|
|
|
|
Use the named program as the program to decompress the input.
|
|
|
|
.It Fl Fl force-local
|
|
|
|
Do not interpret filenames that contain a
|
|
|
|
.Sq \&:
|
|
|
|
as remote files.
|
|
|
|
.It Fl Fl insecure
|
|
|
|
Normally
|
|
|
|
.Nm
|
|
|
|
ignores filenames that contain
|
|
|
|
.Dq ..
|
|
|
|
as a path component.
|
|
|
|
With this option, files that contain
|
|
|
|
.Dq ..
|
|
|
|
can be processed.
|
|
|
|
.It Fl Fl no-recursion
|
|
|
|
Cause files of type directory being copied or archived, or archive members of
|
|
|
|
type directory being extracted, to match only the directory file or archive
|
|
|
|
member and not the file hierarchy rooted at the directory.
|
2010-02-24 12:58:10 +01:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The options
|
|
|
|
.Op Fl 014578
|
|
|
|
can be used to select one of the compiled-in backup devices,
|
2012-10-22 16:10:38 +02:00
|
|
|
.Pa /dev/rstN .
|
2010-02-24 12:58:10 +01:00
|
|
|
.Sh FILES
|
2012-10-22 16:10:38 +02:00
|
|
|
.Bl -tag -width "/dev/rst0"
|
|
|
|
.It Pa /dev/rst0
|
2010-02-24 12:58:10 +01:00
|
|
|
default archive name
|
|
|
|
.El
|
2012-10-22 16:10:38 +02:00
|
|
|
.Sh DIAGNOSTICS
|
2010-02-24 12:58:10 +01:00
|
|
|
.Nm
|
2012-10-22 16:10:38 +02:00
|
|
|
will exit with one of the following values:
|
2010-02-24 12:58:10 +01: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.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr cpio 1 ,
|
|
|
|
.Xr pax 1
|
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm
|
|
|
|
command first appeared in
|
|
|
|
.At v7 .
|
|
|
|
.Sh AUTHORS
|
2012-10-22 16:10:38 +02:00
|
|
|
Keith Muller at the University of California, San Diego.
|