TAR(1) | General Commands Manual | TAR(1) |
tar
—
tar |
[-]{crtux}[-014578befHhJjklmOoPpqSvwXZz ]
[archive] [blocksize]
[-C directory]
[-s replstr]
[-T file]
[file ...] |
tar
command creates, adds files to, or extracts
files from an archive file in “tar” format. A tar archive is
often stored on a magnetic tape, but can be stored equally well on a floppy,
CD-ROM, or in a regular disk file.
One of the following flags must be present:
-c
,
-
-create
-r
,
-
-append
-t
,
-
-list
-u
,
-
-update
-r
.-x
,
-
-extract
,
-
-get
In addition to the flags mentioned above, any of the following flags may be used:
-b
blocking factor,
-
-block-size
blocking factortar
uses 512 byte blocks. The default is 20, the maximum is 126. Archives with
a blocking factor larger 63 violate the POSIX standard and will not be
portable to all systems.-e
-f
archive,
-
-file
archive-h
,
-
-dereference
-J
,
-
-xz
-j
,
-
-bzip2
,
-
-bunzip2
-k
,
-
-keep-old-files
-l
,
-
-one-file-system
-m
,
-
-modification-time
-O
-o
,
-
-portability
,
-
-old-archive
tar
is unable to decode. This implies the
-O
flag.-p
,
-
-preserve-permissions
,
-
-preserve
-x
flag.-q
,
-
-fast-read
-S
,
-
-sparse
tar
always generates
sparse files.-s
replstr/old/new/[gps]
old
is a basic regular expression and
new
can contain an ampersand (&), \n (where n
is a digit) back-references, or subexpression matching. The
old
string may also contain
⟨newline
⟩ characters. Any non-null
character except a backslash (\) can be used as a delimiter (/ is shown
here). Multiple -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 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
g
option. The optional trailing
p
will cause the final result of a successful
substitution to be written to standard error
in
the following format:
⟨original pathname⟩
>> ⟨new pathname⟩
s
prevents the substitutions from being performed
on symbolic link destinations.-v
-w
,
-
-interactive
,
-
-confirmation
tar
to prompt the user for the filename to use when storing or extracting
files in an archive.-z
,
-
-gzip
,
-
-gunzip
-B
,
-
-read-full-blocks
-C
directory,
-
-directory
directory-T
.-H
Note SysVr3/i386 picked up ISC/SCO UNIX compatibility which
implemented “-F
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 “-I
file” because they use
‘-F
’ to mean something else. We
might someday provide SunOS-5 compatibility but it makes little sense to
confuse things with ISC/SCO compatibility.
-P
,
-
-absolute-paths
-T
file,
-
-files-from
file-C
directory”.-X
file,
-
-exclude-from
fileNote that it would be more standard to use this option to mean ``do not cross filesystem mount points.''
-Z
,
-
-compress
,
-
-uncompress
-
-strict
-
-atime-preserve
-
-chroot
chroot
() to the current directory before
extracting files. Use with -x
and
-h
to make absolute symlinks relative to the
current directory.-
-unlink
tar
implementations. tar
always unlinks files before creating them.-
-use-compress-program
program-
-force-local
-
-insecure
tar
ignores filenames that contain
“..” as a path component. With this option, files that
contain “..” can be processed.-
-no-recursion
-
-timestamp
timestampThe options [-014578
] can be used to
select one of the compiled-in backup devices,
/dev/rstN.
tar
will exit with one of the following values:
Whenever tar
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 -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
tar
cannot create a link to a file,
tar
will not create a second copy of the file.
If the extraction of a file from an archive is prematurely
terminated by a signal or error, tar
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.
If the creation of an archive is prematurely terminated by a
signal or error, tar
may have only partially created
the archive which may violate the specific archive format specification.
tar
command first appeared in
Version 7 AT&T UNIX.
March 19, 2019 | NetBSD 8.99 |