Note that the
options must be supplied as a single group, with no spaces in between. A preceding hyphen (
) is allowed but not required .
Specifying options with
tar command is unusual because you do not need to put a hyphen (-) before the options. In the earliest UNIX versions, you were not supposed to use a
the options; otherwise, you would generate an error. As UNIX evolved, users felt that the commands needed to be more consistent. Newer versions of UNIX therefore began allowing the
tar options, but it wasn’t required.
tar command allows a hyphen only before the first option. In addition, all options must be listed together, without spaces between them. The following table summarizes the basic syntax for the
tar command. Notice that the first example is incorrect because it contains multiple hyphens and includes spaces between the options.
| Command || Comment |
tar –c –v –f bigfile.tar my_dir
| Not allowed |
tar –cvf bigfile.tar my_dir
| Allowed |
tar cvf bigfile.tar my_dir
| Allowed |
option stands for create
. When you create an archive,
is required and must go first. The
stands for verbose
. It’s optional but recommended. The
to list file names as they are being
option is used along with the
argument, which is explained below.