[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.3.3 Old Option Style
As far as we know, all tar
programs, GNU and
non-GNU, support old options: that is, if the first
argument does not start with ‘-’, it is assumed to specify option
letters. GNU tar
supports old options not only for historical
reasons, but also because many people are used to them. If the first
argument does not start with a dash, you are announcing the old option
style instead of the short option style; old options are decoded
differently.
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. This set
of letters must be the first to appear on the command line, after the
tar
program name and some white space; 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
long option ‘--list’. So for example, the command ‘tar cv’ specifies the option ‘-v’ in addition to the operation ‘-c’.
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’.
The old style syntax can make 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.
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
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on November 1, 2013 using texi2html 5.0.