Go to the first, previous, next, last section, table of contents.


Old Option Style

@UNREVISED

Like short options, old options are single letters. However, old options must be written together as a single clumped set, without spaces separating them or dashes preceding them(2). This set of letters must be the first to appear on the command line, after the tar program name and some whitespace; old options cannot appear anywhere else. The letter of an old option is exactly the same letter as the corresponding short option. For example, the old option `t' is the same as the short option `-t', and consequently, the same as the mnemonic option `--list'. So for example, the command `tar cv' specifies the option `-v' in addition to the operation `-c'.

@FIXME{bob suggests having an uglier example. :-) }

When options that need arguments are given together with the command, all the associated arguments follow, in the same order as the options. Thus, the example given previously could also be written in the old style as follows:

$ tar cvbf 20 /dev/rmt0

Here, `20' is the argument of `-b' and `/dev/rmt0' is the argument of `-f'.

On the other hand, this old style syntax makes it difficult to match option letters with their corresponding arguments, and is often confusing. In the command `tar cvbf 20 /dev/rmt0', for example, `20' is the argument for `-b', `/dev/rmt0' is the argument for `-f', and `-v' does not have a corresponding argument. Even using short options like in `tar -c -v -b 20 -f /dev/rmt0' is clearer, putting all arguments next to the option they pertain to.

If you want to reorder the letters in the old option argument, be sure to reorder any corresponding argument appropriately.

This old way of writing tar options can surprise even experienced users. For example, the two commands:

tar cfz archive.tar.gz file
tar -cfz archive.tar.gz file

are quite different. The first example uses `archive.tar.gz' as the value for option `f' and recognizes the option `z'. The second example, however, uses `z' as the value for option `f'---probably not what was intended.

Old options are kept for compatibility with old versions of tar.

This second example could be corrected in many ways, among which the following are equivalent:

tar -czf archive.tar.gz file
tar -cf archive.tar.gz -z file
tar cf archive.tar.gz -z file

@FIXME{still could explain this better; it's redundant:}

As far as we know, all tar programs, GNU and non-GNU, support old options. GNU tar supports them not only for historical reasons, but also because many people are used to them. For compatibility with Unix tar, the first argument is always treated as containing command and option letters even if it doesn't start with `-'. Thus, `tar c' is equivalent to `tar -c:' both of them specify the --create (-c) command to create an archive.


Go to the first, previous, next, last section, table of contents.