tar command syntax
Last revision July 20, 2004
Additional topics:
|
The basic syntax for the tar program is:
tar operation [options] [files]
You substitute values for the italicized items. The brackets show optional arguments -- if you use them, do not type the brackets themselves!
One operation, either creating, listing, or restoring an archive, is always required and is specified by a single letter:
| c | create a new archive |
| t | list the contents of an existing archive |
| x | extract (restore) files from an existing archive |
Options are also usually a single letter, may take an argument (another following word that expands upon the option), and are not introduced by a hyphen or minus sign (-) as Unix command options usually are.
The files argument is required to create an archive and may also be optionally used to limit the listing or extracting of files from an existing archive. You can supply any number of files or directories as arguments. When a directory name is encountered, the entire directory tree, including any number or level of sub-directories, is used.
A typical tar command to create a new archive is intended to get an entire directory tree. In that case, the simplest method that causes the fewest problems when extracting files later (see discussion of pathnames) is to change your working directory to be the desired one, and then run tar with the period character (.), meaning the "current directory", as the files argument.