[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
tar
OptionsThe coming manual sections contain an alphabetical listing of all
tar
operations and options, with brief descriptions and
cross-references to more in-depth explanations in the body of the manual.
They also contain an alphabetically arranged table of the short option
forms with their corresponding long option. You can use this table as
a reference for deciphering tar
commands in scripts.
3.4.1 Operations | ||
3.4.2 tar Options | ||
3.4.3 Short Options Cross Reference | ||
3.4.4 Position-Sensitive Options |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Appends files to the end of the archive. See section How to Add Files to Existing Archives: ‘--append’.
Same as ‘--concatenate’. See section Combining Archives with ‘--concatenate’.
Compares archive members with their counterparts in the file system, and reports differences in file size, mode, owner, modification date and contents. See section Comparing Archive Members with the File System.
Appends other tar
archives to the end of the archive.
See section Combining Archives with ‘--concatenate’.
Creates a new tar
archive. See section How to Create Archives.
Deletes members from the archive. Don’t try this on an archive on a tape! See section Removing Archive Members Using ‘--delete’.
Same as ‘--compare’. See section Comparing Archive Members with the File System.
Extracts members from the archive into the file system. See section How to Extract Members from an Archive.
Same as ‘--extract’. See section How to Extract Members from an Archive.
Lists the members in an archive. See section How to List Archives.
Adds files to the end of the archive, but only if they are newer than their counterparts already in the archive, or if they do not already exist in the archive. See section Updating an Archive.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
tar
OptionsNormally when creating an archive, tar
strips an initial
‘/’ from member names, and when extracting from an archive tar
treats names specially if they have initial ‘/’ or internal
‘..’. This option disables that behavior. See section Absolute File Names.
Enable POSIX ACLs support. See section acls.
(See ‘--newer’, see section Operating Only on New Files)
A pattern must match an initial subsequence of the name’s components. See section Controlling Pattern-Matching.
Attempt to preserve the access time of files when reading them. This option currently is effective only on files that you own, unless you have superuser privileges.
‘--atime-preserve=replace’ remembers the access time of a file
before reading it, and then restores the access time afterwards. This
may cause problems if other programs are reading the file at the same
time, as the times of their accesses will be lost. On most platforms
restoring the access time also requires tar
to restore the
data modification time too, so this option may also cause problems if
other programs are writing the file at the same time (tar
attempts
to detect this situation, but cannot do so reliably due to race
conditions). Worse, on most platforms restoring the access time also
updates the status change time, which means that this option is
incompatible with incremental backups.
‘--atime-preserve=system’ avoids changing time stamps on files,
without interfering with time stamp updates
caused by other programs, so it works better with incremental backups.
However, it requires a special O_NOATIME
option from the
underlying operating and file system implementation, and it also requires
that searching directories does not update their access times. As of
this writing (November 2005) this works only with Linux, and only with
Linux kernels 2.6.8 and later. Worse, there is currently no reliable
way to know whether this feature actually works. Sometimes
tar
knows that it does not work, and if you use
‘--atime-preserve=system’ then tar
complains and
exits right away. But other times tar
might think that the
option works when it actually does not.
Currently ‘--atime-preserve’ with no operand defaults to ‘--atime-preserve=replace’, but this may change in the future as support for ‘--atime-preserve=system’ improves.
If your operating or file system does not support
‘--atime-preserve=system’, you might be able to preserve access
times reliably by using the mount
command. For example,
you can mount the file system read-only, or access the file system via
a read-only loopback mount, or use the ‘noatime’ mount option
available on some systems. However, mounting typically requires
superuser privileges and can be a pain to manage.
During a ‘--create’ operation, enables automatic compressed format recognition based on the archive suffix. The effect of this option is cancelled by ‘--no-auto-compress’. See section Creating and Reading Compressed Archives.
Rather than deleting files from the file system, tar
will
back them up using simple or numbered backups, depending upon
backup-type. See section Backup options.
With this option present, tar
prints error messages for read errors
with the block number in the archive file. See block-number.
Sets the blocking factor tar
uses to blocking x 512 bytes per
record. See section The Blocking Factor of an Archive.
This option tells tar
to read or write archives through
bzip2
. See section Creating and Reading Compressed Archives.
Check device numbers when creating a list of modified files for incremental archiving. This is the default. See device numbers, for a detailed description.
This option directs tar
to print periodic checkpoint
messages as it reads through the archive. It is intended for when you
want a visual indication that tar
is still running, but
don’t want to see ‘--verbose’ output. You can also instruct
tar
to execute a list of actions on each checkpoint, see
‘--checkpoint-action’ below. For a detailed description, see
Checkpoints.
Instruct tar
to execute an action upon hitting a
breakpoint. Here we give only a brief outline. See section Checkpoints,
for a complete description.
The action argument can be one of the following:
Produce an audible bell on the console.
Print a single dot on the standard listing stream.
Display a textual message on the standard error, with the status and number of the checkpoint. This is the default.
Display string on the standard error. Before output, the string is subject to meta-character expansion.
Execute the given command.
Wait for time seconds.
Output string on the current console (‘/dev/tty’).
Print statistics (see see totals).
Wait for signal signo.
Several ‘--checkpoint-action’ options can be specified. The supplied actions will be executed in order of their appearance in the command line.
Using ‘--checkpoint-action’ without ‘--checkpoint’ assumes default checkpoint frequency of one checkpoint per 10 records.
If this option was given, tar
will check the number of links
dumped for each processed file. If this number does not match the
total number of hard links for the file, a warning message will be
output (5).
See section Hard Links.
tar
will use the compress
program when reading or
writing the archive. This allows you to directly act on archives
while saving space. See section Creating and Reading Compressed Archives.
(See ‘--mtime’.)
(See ‘--interactive’.) See section Asking for Confirmation During Operations.
Delay setting modification times and permissions of extracted directories until the end of extraction. See section Directory Modification Times and Permissions.
When reading or writing a file to be archived, tar
accesses
the file that a symbolic link points to, rather than the symlink
itself. See section Symbolic Links.
When this option is specified, tar
will change its current directory
to dir before performing any operations. When this option is used
during archive creation, it is order sensitive. See section Changing the Working Directory.
When performing operations, tar
will skip files that match
pattern. See section Excluding Some Files.
Exclude backup and lock files. See section exclude-backups.
Similar to ‘--exclude’, except tar
will use the list of
patterns in the file file. See section Excluding Some Files.
Exclude from dump any directory containing a valid cache directory tag file, but still dump the directory node and the tag file itself.
See section exclude-caches.
Exclude from dump any directory containing a valid cache directory tag file, but still dump the directory node itself.
See section Excluding Some Files.
Exclude from dump any directory containing a valid cache directory tag file. See section Excluding Some Files.
Before dumping a directory, tar
checks if it contains
file. If so, exclusion patterns are read from this file.
The patterns affect only the directory itself. See section Excluding Some Files.
Before dumping a directory, tar
checks if it contains
file. If so, exclusion patterns are read from this file.
The patterns affect the directory and all itssubdirectories.
See section Excluding Some Files.
Exclude from dump any directory containing file named file, but dump the directory node and file itself. See section exclude-tag.
Exclude from dump the contents of any directory containing file named file, but dump the directory node itself. See section exclude-tag-under.
Exclude from dump any directory containing file named file. See section exclude-tag-all.
Exclude from dump directories and files, that are internal for some widely used version control systems.
See exclude-vcs.
Exclude files that match patterns read from VCS-specific ignore files. Supported files are: ‘.cvsignore’, ‘.gitignore’, ‘.bzrignore’, and ‘.hgignore’. The semantics of each file is the same as for the corresponding VCS, e.g. patterns read from ‘.gitignore’ affect the directory and all its subdirectories. See exclude-vcs-ignores.
tar
will use the file archive as the tar
archive it
performs operations on, rather than tar
’s compilation dependent
default. See section The ‘--file’ Option.
tar
will use the contents of file as a list of archive members
or files to operate on, in addition to those specified on the
command-line. See section Reading Names from a File.
Forces tar
to interpret the file name given to ‘--file’
as a local file, even if it looks like a remote tape drive name.
See local and remote archives.
Selects output archive format. Format may be one of the following:
Creates an archive that is compatible with Unix V7 tar
.
Creates an archive that is compatible with GNU tar
version
1.12 or earlier.
Creates archive in GNU tar 1.13 format. Basically it is the same as ‘oldgnu’ with the only difference in the way it handles long numeric fields.
Creates a POSIX.1-1988 compatible archive.
Creates a POSIX.1-2001 archive.
See section Controlling the Archive Format, for a detailed discussion of these formats.
This option instructs tar
to print file times to their full
resolution. Usually this means 1-second resolution, but that depends
on the underlying file system. The ‘--full-time’ option takes
effect only when detailed output (verbosity level 2 or higher) has
been requested using the ‘--verbose’ option, e.g., when listing
or extracting archives:
$ tar -t -v --full-time -f archive.tar
or, when creating an archive:
$ tar -c -vv --full-time -f archive.tar .
Notice, thar when creating the archive you need to specify ‘--verbose’ twice to get a detailed output (see section The ‘--verbose’ Option).
Files added to the tar
archive will have a group ID of group,
rather than the group from the source file. group can specify a
symbolic name, or a numeric ID, or both as
name:id. See section Overriding File Metadata.
Also see the ‘--group-map’ option and comments for the ‘--owner=user’ option.
Read owner group translation map from file. This option allows to translate only certain group names and/or UIDs. See section Overriding File Metadata, for a detailed description. When used together with ‘--group’ option, the latter affects only those files whose owner group is not listed in the file.
This option does not affect extraction from archives.
This option tells tar
to read or write archives through
gzip
, allowing tar
to directly operate on several
kinds of compressed archives transparently. See section Creating and Reading Compressed Archives.
When creating an archive, dereference hard links and store the files they refer to, instead of creating usual hard link members.
See section Hard Links.
tar
will print out a short message summarizing the operations and
options to tar
and exit. See section GNU tar
documentation.
Use method to detect holes in sparse files. This option implies ‘--sparse’. Valid methods are ‘seek’ and ‘raw’. Default is ‘seek’ with fallback to ‘raw’ when not applicable. See section Archiving Sparse Files.
Ignore case when matching member or file names with patterns. See section Controlling Pattern-Matching.
Ignore exit codes of subprocesses. See section Writing to an External Program.
Do not exit unsuccessfully merely because reading failed. See section Ignore Failed Read.
With this option, tar
will ignore zeroed blocks in the
archive, which normally signals EOF. This option also suppresses
warnings about missing or incomplete zero blocks at the end of the
archive. See section Ignoring Blocks of Zeros.
Informs tar
that it is working with an old
GNU-format incremental backup archive. It is intended
primarily for backwards compatibility only. See section Using tar
to Perform Incremental Dumps,
for a detailed discussion of incremental archives.
Send verbose output to file instead of to standard output.
When tar
is performing multi-tape backups, command is run
at the end of each tape. If it exits with nonzero status,
tar
fails immediately. See info-script, for a detailed
discussion of this feature.
Specifies that tar
should ask the user for confirmation before
performing potentially destructive options, such as overwriting files.
See section Asking for Confirmation During Operations.
This option changes the behavior of tar when it encounters a symlink with the same name as the directory that it is about to extract. By default, in this case tar would first remove the symlink and then proceed extracting the directory.
The ‘--keep-directory-symlink’ option disables this behavior and instructs tar to follow symlinks to directories when extracting from the archive.
It is mainly intended to provide compatibility with the Slackware installation scripts.
Do not replace existing files that are newer than their archive copies when extracting files from an archive.
Do not overwrite existing files when extracting files from an archive. Return error if such files exist. See also --skip-old-files.
See section Keep Old Files.
When creating an archive, instructs tar
to write name
as a name record in the archive. When extracting or listing archives,
tar
will only operate on archives that have a label matching
the pattern specified in name. See section Tape Files.
Force incremental backup of level n. As of GNU tar
version
1.35, the option ‘--level=0’ truncates the snapshot
file, thereby forcing the level 0 dump. Other values of n are
effectively ignored. See --level=0, for details and examples.
The use of this option is valid only in conjunction with the
‘--listed-incremental’ option. See section Using tar
to Perform Incremental Dumps,
for a detailed description.
During a ‘--create’ operation, specifies that the archive that
tar
creates is a new GNU-format incremental
backup, using snapshot-file to determine which files to backup.
With other operations, informs tar
that the archive is in
incremental format. See section Using tar
to Perform Incremental Dumps.
This option tells tar
to read or write archives through
lzip
. See section Creating and Reading Compressed Archives.
This option tells tar
to read or write archives through
lzma
. See section Creating and Reading Compressed Archives.
This option tells tar
to read or write archives through
lzop
. See section Creating and Reading Compressed Archives.
When adding files to an archive, tar
will use
permissions for the archive members, rather than the permissions
from the files. permissions can be specified either as an octal
number or as symbolic permissions, like with
chmod
. See section Overriding File Metadata.
When adding files to an archive, tar
will use date as
the modification time of members when creating archives, instead of
their actual modification times. The value of date can be
either a textual date representation (see section Date input formats) or a
name of the existing file, starting with ‘/’ or ‘.’. In the
latter case, the modification time of that file is used. See section Overriding File Metadata.
When --clamp-mtime
is also specified, files with
modification times earlier than date will retain their actual
modification times, and date will be used only for files with
modification times later than date.
Informs tar
that it should create or otherwise operate on a
multi-volume tar
archive. See section Using Multiple Tapes.
(see ‘--info-script’)
When creating an archive, tar
will only add files that have changed
since date. If date begins with ‘/’ or ‘.’, it
is taken to be the name of a file whose data modification time specifies
the date. See section Operating Only on New Files.
Like ‘--newer’, but add only files whose contents have changed (as opposed to just ‘--newer’, which will also back up files for which any status information has changed). See section Operating Only on New Files.
Disable the POSIX ACLs support. See section acls.
An exclude pattern can match any subsequence of the name’s components. See section Controlling Pattern-Matching.
Disables automatic compressed format recognition based on the archive suffix. See --auto-compress. See section Creating and Reading Compressed Archives.
Do not check device numbers when creating a list of modified files for incremental archiving. See device numbers, for a detailed description.
Modification times and permissions of extracted directories are set when all files from this directory have been extracted. This is the default. See section Directory Modification Times and Permissions.
Use case-sensitive matching. See section Controlling Pattern-Matching.
Print warnings about subprocesses that terminated with a nonzero exit code. See section Writing to an External Program.
If the ‘--null’ option was given previously, this option cancels its effect, so that any following ‘--files-from’ options will expect their file lists to be newline-terminated.
Preserve metadata of existing directories when extracting files from an archive. See section Overwrite Old Files.
Remove characters listed in string from the list of quoted characters set by the previous ‘--quote-chars’ option (see section Quoting Member Names).
With this option, tar
will not recurse into directories.
See section Descending into Directories.
When extracting an archive, do not attempt to preserve the owner
specified in the tar
archive. This the default behavior
for ordinary users.
When extracting an archive, subtract the user’s umask from files from the permissions specified in the archive. This is the default behavior for ordinary users.
The archive media does not support seeks to arbitrary
locations. Usually tar
determines automatically whether
the archive can be seeked or not. Use this option to disable this
mechanism.
Disable SELinux context support. See section SELinux.
Treat all input file or member names literally, do not interpret escape sequences. See input name quoting.
Instructs GNU tar
to treat each line read from a file list as if it
were supplied in the command line. I.e., leading and trailing
whitespace is removed and, if the result begins with a dash, it is
treated as a GNU tar
command line option.
This is default behavior. This option is provided as a way to restore it after ‘--verbatim-files-from’ option.
It is implied by the ‘--no-null’ option.
Do not use wildcards. See section Controlling Pattern-Matching.
Wildcards do not match ‘/’. See section Controlling Pattern-Matching.
Disable extended attributes support. See section xattrs.
When tar
is using the ‘--files-from’ option, this option
instructs tar
to expect file names terminated with
NUL, and to process file names verbatim.
This means that tar
correctly works with file names that
contain newlines or begin with a dash.
See section NUL
-Terminated File Names.
See also verbatim-files-from.
This option will notify tar
that it should use numeric user
and group IDs when creating a tar
file, rather than names.
See section Handling File Attributes.
The function of this option depends on the action tar
is
performing. When extracting files, ‘-o’ is a synonym for
‘--no-same-owner’, i.e., it prevents tar
from
restoring ownership of files being extracted.
When creating an archive, it is a synonym for
‘--old-archive’. This behavior is for compatibility
with previous versions of GNU tar
, and will be
removed in future releases.
See section Changes, for more information.
This option can be used in conjunction with one of the subcommands ‘--delete’, ‘--diff’, ‘--extract’ or ‘--list’ when a list of files is given either on the command line or via ‘-T’ option.
This option instructs tar
to process only the numberth
occurrence of each named file. Number defaults to 1, so
tar -x -f archive.tar --occurrence filename
will extract the first occurrence of the member ‘filename’ from ‘archive.tar’ and will terminate without scanning to the end of the archive.
Synonym for ‘--format=v7’.
Used when creating an archive. Prevents tar
from recursing into
directories that are on different file systems from the current
directory.
Tells tar
to create a new directory beneath the extraction directory
(or the one passed to ‘-C’) and use it to guard against
tarbombs. In the absence of dir argument, the name of the new directory
will be equal to the base name of the archive (file name minus the
archive suffix, if recognized). Any member names that do not begin
with that directory name (after
transformations from ‘--transform’ and
‘--strip-components’) will be prefixed with it. Recognized
file name suffixes are ‘.tar’, and any compression suffixes
recognizable by See --auto-compress.
Overwrite existing files and directory metadata when extracting files from an archive. See section Overwrite Old Files.
Overwrite the metadata of existing directories when extracting files from an archive. See section Overwrite Old Files.
Specifies that tar
should use user as the owner of members
when creating archives, instead of the user associated with the source
file. user can specify a symbolic name, or a numeric
ID, or both as name:id.
See section Overriding File Metadata.
This option does not affect extraction from archives. See also ‘--owner-map’, below.
Read owner translation map from file. This option allows to translate only certain owner names or UIDs. See section Overriding File Metadata, for a detailed description. When used together with ‘--owner’ option, the latter affects only those files whose owner is not listed in the file.
This option does not affect extraction from archives.
This option enables creation of the archive in POSIX.1-2001
format (see section GNU tar
and POSIX tar
) and modifies the way tar
handles the
extended header keywords. Keyword-list is a comma-separated
list of keyword options. See section Controlling Extended Header Keywords, for a detailed
discussion.
Synonym for ‘--format=v7’.
Same as ‘--format=posix’.
(See ‘--same-order’; see section Same Order.)
When tar
is extracting an archive, it normally subtracts the
users’ umask from the permissions specified in the archive and uses
that number as the permissions to create the destination file.
Specifying this option instructs tar
that it should use the
permissions directly from the archive. See section Setting Access Permissions.
Always quote characters from string, even if the selected quoting style would not quote them (see section Quoting Member Names).
Set quoting style to use when printing member and file names
(see section Quoting Member Names). Valid style values are:
literal
, shell
, shell-always
, c
,
escape
, locale
, and clocale
. Default quoting
style is escape
, unless overridden while configuring the
package.
Specifies that tar
should reblock its input, for reading
from pipes on systems with buggy implementations. See section Options to Help Read Archives.
Instructs tar
to use size bytes per record when accessing the
archive. The argument can be suffixed with a size suffix, e.g.
‘--record-size=10K’ for 10 Kilobytes. See Table 9.1,
for a list of valid suffixes. See section The Blocking Factor of an Archive, for a detailed
description of this option.
With this option, tar
recurses into directories (default).
See section Descending into Directories.
Remove existing directory hierarchies before extracting directories of the same name from the archive. See section Recursive Unlink.
Directs tar
to remove the source file from the file system after
appending it to an archive. See section Removing Files.
Disable use of some potentially harmful tar
options.
Currently this option disables shell invocation from multi-volume menu
(see section Using Multiple Tapes).
Notifies tar
that it should use cmd instead of
the default ‘/usr/libexec/rmt’ (see section Remote Tape Server).
Notifies tar
that is should use cmd to communicate with remote
devices. See section Device Selection and Switching.
This option is an optimization for tar
when running on machines with
small amounts of memory. It informs tar
that the list of file
arguments has already been sorted to match the order of files in the
archive. See section Same Order.
When extracting an archive, tar
will attempt to preserve the owner
specified in the tar
archive with this option present.
This is the default behavior for the superuser; this option has an
effect only for ordinary users. See section Handling File Attributes.
(See ‘--preserve-permissions’; see section Setting Access Permissions.)
Assume that the archive media supports seeks to arbitrary
locations. Usually tar
determines automatically whether
the archive can be seeked or not. This option is intended for use
in cases when such recognition fails. It takes effect only if the
archive is open for reading (e.g. with ‘--list’ or
‘--extract’ options).
Enable the SELinux context support. See section selinux.
Displays the default options used by tar
and exits
successfully. This option is intended for use in shell scripts.
Here is an example of what you can see using this option:
$ tar --show-defaults --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
Notice, that this option outputs only one line. The example output
above has been split to fit page boundaries. See section Obtaining GNU tar
default values.
Instructs tar
to mention the directories it is skipping when
operating on a tar
archive. See show-omitted-dirs.
Displays the range of values allowed by this version of tar
for each field in the snapshot file, then exits successfully.
See section Format of the Incremental Snapshot Files.
Display file or member names after applying any transformations
(see section Modifying File and Member Names). In particular, when used in conjunction with one of
the archive creation operations it instructs tar
to list the
member names stored in the archive, as opposed to the actual file
names. See listing member and file names.
Do not overwrite existing files when extracting files from an archive. See section Keep Old Files.
This option differs from ‘--keep-old-files’ in that it does not treat such files as an error, instead it just silently avoids overwriting them.
The ‘--warning=existing-file’ option can be used together with this option to produce warning messages about existing old files (see section Controlling Warning Messages).
Specify the directory sorting order when reading directories. Order may be one of the following:
No directory sorting is performed. This is the default.
Sort the directory entries on name. The operating system may deliver
directory entries in a more or less random order, and sorting them
makes archive creation more reproducible. See section Making tar
Archives More Reproducible.
Sort the directory entries on inode number. Sorting directories on inode number may reduce the amount of disk seek operations when creating an archive for some file systems.
Invokes a GNU extension when adding files to an archive that handles sparse files efficiently. See section Archiving Sparse Files.
Specifies the format version to use when archiving sparse files. Implies ‘--sparse’. See section Archiving Sparse Files. For the description of the supported sparse formats, See section Storing Sparse Files.
This option affects extraction only; tar
will skip extracting
files in the archive until it finds one that matches name.
See section Coping with Scarce Resources.
Strip given number of leading components from file names before extraction. For example, if archive ‘archive.tar’ contained ‘/some/file/name’, then running
tar --extract --file archive.tar --strip-components=2
would extract this file to file ‘name’.
See section Modifying File and Member Names.
Alters the suffix tar
uses when backing up files from the default
‘~’. See section Backup options.
Specifies the length of tapes that tar
is writing as being
num x 1024 bytes long. If optional suf is given, it
specifies a multiplicative factor to be used instead of 1024. For
example, ‘-L2M’ means 2 megabytes. See Table 9.1, for a
list of allowed suffixes. See section Using Multiple Tapes, for a detailed
discussion of this option.
Reads the volume label. If an argument is specified, test whether it matches the volume label. See --test-label option.
During extraction tar
will pipe extracted files to the
standard input of command. See section Writing to an External Program.
During extraction, tar
will extract files to stdout rather
than to the file system. See section Writing to Standard Output.
Displays the total number of bytes transferred when processing an
archive. If an argument is given, these data are displayed on
request, when signal signo is delivered to tar
.
See totals.
Sets the data modification time of extracted files to the extraction time, rather than the data modification time stored in the archive. See section Setting Data Modification Times.
Transform file or member names using sed
replacement expression
sed-expr. For example,
$ tar cf archive.tar --transform 's,^\./,usr/,' .
will add to ‘archive’ files from the current working directory, replacing initial ‘./’ prefix with ‘usr/’. For the detailed discussion, See section Modifying File and Member Names.
To see transformed member names in verbose listings, use ‘--show-transformed-names’ option (see show-transformed-names).
(See ‘--compress’, see section Creating and Reading Compressed Archives)
(See ‘--gzip’, see section Creating and Reading Compressed Archives)
Directs tar
to remove the corresponding file from the file
system before extracting it from the archive. See section Unlink First.
Enable unquoting input file or member names (default). See input name quoting.
Instructs tar
to access the archive through prog, which is
presumed to be a compression program of some sort. See section Creating and Reading Compressed Archives.
Display file modification dates in UTC. This option implies ‘--verbose’.
Instructs GNU tar
to treat each line read from a file list as a file
name, even if it starts with a dash.
File lists are supplied with the ‘--files-from’ (‘-T’)
option. By default, each line read from a file list is first trimmed
off the leading and trailing whitespace and, if the result begins with
a dash, it is treated as a GNU tar
command line option.
Use the ‘--verbatim-files-from’ option to disable this special
handling. This facilitates the use of tar
with file lists
created by file
command.
This option affects all ‘--files-from’ options that occur after it in the command line. Its effect is reverted by the ‘--no-verbatim-files-from’ option.
This option is implied by the ‘--null’ option.
See verbatim-files-from.
Specifies that tar
should be more verbose about the
operations it is performing. This option can be specified multiple
times for some operations to increase the amount of information displayed.
See section Checking tar
progress.
Verifies that the archive was correctly written when creating an archive. See section Verifying Data as It is Stored.
Print information about the program’s name, version, origin and legal
status, all on standard output, and then exit successfully.
See section GNU tar
documentation.
Used in conjunction with ‘--multi-volume’. tar
will
keep track of which volume of a multi-volume archive it is working in
file. See volno-file.
Enable or disable warning messages identified by keyword. The messages are suppressed if keyword is prefixed with ‘no-’. See section Controlling Warning Messages.
Use wildcards when matching member names with patterns. See section Controlling Pattern-Matching.
Wildcards match ‘/’. See section Controlling Pattern-Matching.
Enable extended attributes support. See section xattrs.
Specify exclude pattern for xattr keys. See section xattrs-exclude.
Specify include pattern for xattr keys. pattern is a globbing pattern, e.g. ‘--xattrs-include='user.*'’ to include only attributes from the user namespace. See section xattrs-include.
Use xz
for compressing or decompressing the archives. See section Creating and Reading Compressed Archives.
Use zstd
for compressing or decompressing the archives. See section Creating and Reading Compressed Archives.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is an alphabetized list of all of the short option forms, matching them with the equivalent long option.
Short Option | Reference |
---|---|
-A | --concatenate. |
-B | --read-full-records. |
-C | --directory. |
-F | --info-script. |
-G | --incremental. |
-J | --xz. |
-K | --starting-file. |
-L | --tape-length. |
-M | --multi-volume. |
-N | --newer. |
-O | --to-stdout. |
-P | --absolute-names. |
-R | --block-number. |
-S | --sparse. |
-T | --files-from. |
-U | --unlink-first. |
-V | --label. |
-W | --verify. |
-X | --exclude-from. |
-Z | --compress. |
-b | --blocking-factor. |
-c | --create. |
-d | --compare. |
-f | --file. |
-g | --listed-incremental. |
-h | --dereference. |
-i | --ignore-zeros. |
-j | --bzip2. |
-k | --keep-old-files. |
-l | --check-links. |
-m | --touch. |
-o | When extracting, same as --no-same-owner. When creating,
– --old-archive.
The latter usage is deprecated. It is retained for compatibility with
the earlier versions of GNU |
-p | --preserve-permissions. |
-r | --append. |
-s | --same-order. |
-t | --list. |
-u | --update. |
-v | --verbose. |
-w | --interactive. |
-x | --extract. |
-z | --gzip. |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Some GNU tar
options can be used multiple times in the same
invocation and affect all arguments that appear after them. These are
options that control how file names are selected and what kind of
pattern matching is used.
The most obvious example is the ‘-C’ option. It instructs tar
to change to the directory given as its argument prior to processing
the rest of command line (see section Changing the Working Directory). Thus, in the following
command:
tar -c -f a.tar -C /etc passwd -C /var log spool
the file ‘passwd’ will be searched in the directory ‘/etc’, and files ‘log’ and ‘spool’ – in ‘/var’.
These options can also be used in a file list supplied with the ‘--files-from’ (‘-T’) option (see section Reading Names from a File). In that case they affect all files (patterns) appearing in that file after them and remain in effect for any arguments processed after that file. For example, if the file ‘list.txt’ contained:
README -C src main.c
and tar
were invoked as follows:
tar -c -f a.tar -T list.txt Makefile
then the file ‘README’ would be looked up in the current working directory, and files ‘main.c’ and ‘Makefile’ would be looked up in the directory ‘src’.
Many options can be prefixed with ‘--no-’ to cancel the effect of the original option.
For example, the ‘--recursion’ option controls whether to recurse in the subdirectories. It’s counterpart ‘--no-recursion’ disables this. Consider the command below. It will store in the archive the directory ‘/usr’ with all files and directories that are located in it as well as any files and directories in ‘/var’, without recursing into them(6):
tar -cf a.tar --recursion /usr --no-recursion /var/*
During archive creation, GNU tar
keeps track of positional options
used and arguments affected by them. If it finds out that any such
options are used in an obviously erroneous way, the fact is reported
and exit code is set to 2. E.g.:
$ tar -cf a.tar . --exclude '*.o' tar: The following options were used after any non-optional arguments in archive create or update mode. These options are positional and affect only arguments that follow them. Please, rearrange them properly. tar: --exclude '*.o' has no effect tar: Exiting with failure status due to previous errors
The following table summarizes all position-sensitive options.
See section Changing the Working Directory.
See section NUL
-Terminated File Names.
See input name quoting.
See verbatim-files-from.
See section Descending into Directories.
See anchored patterns.
See section Controlling Pattern-Matching.
See section Controlling Pattern-Matching.
See section Excluding Some Files.
See section Excluding Some Files.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |
This document was generated on August 23, 2023 using texi2html 5.0.