Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
NAME
tar - a simple version of the tar archiving utility

SYNOPSIS
tar [OPTION...] TARFILE FILE...

DESCRIPTION
tar stores/extracts files and/or directories to/from an archive file known as a TARFILE. By default, storing a directory to a TARFILE always implies that the subdirectories below should be included in the archive.

OPTIONS
--exclude 'PATTERN[, PATTERN...]'
Exclude files that match the specified PATTERN(s). This option takes no effect if -x option is specified.

--include 'PATTERN[, PATTERN...]'
Include only those files that match the specified PATTERN(s). This option takes no effect if -x option is specified.

-x
Extract files from a TARFILE to the named directory, current directory is assumed if no directory specified.


EXAMPLE
To archive a directory, including its subdirectories, into a TARFILE:
No Format
tar data.tar data_dir


      To archive a directory, excluding the content of its subdirectories, into a TARFILE:
No Format
tar --include '*' data.tar data_dir


       To archive a directory and its subdirectories into a TARFILE without including all of files end with .txt and .html suffixes:
No Format
tar --exclude '**/*.txt, **/*.html' data.tar data_dir


      To archive a directory and its subdirectories into a TARFILE, excluding those files end with .dat suffix in the sub_dir_1 directory:
No Format
tar --exclude '**/sub_dir_1/*.dat' data.tar data_dir


      To archive a set of files and directories into a TARFILE:
No Format
tar data.tar data_1.txt ../data_2.txt data_1_dir ../data_2_dir

NOTES
Upon extraction, tar silently overwrites the files in the destination directory if applicable.

Upon extraction, the result is undefined if a file that is not in tar format is passed to the tar command.

Execution of tar command would fail if invalid patterns are specified by --exclude and --include options, or valid patterns are specified but cause conflict. When this happens, tar terminates with one line message without detail information provided.

SEE ALSO
zip
unzip
gzip
gunzip