Quote:
Originally Posted by babu198649
some options come inside []
|
That means they are not required, but optional.
Quote:
Originally Posted by babu198649
and some with extensions - or -- .
|
The single - before a single character option is the original unix style. Often with this style of option you an "bundle" options together too, for example, these two variations do the same thing - the second is with bundling:
Code:
grep -i -v
grep -iv
The more recent convention of using --long-options is described in detail in the GNU coding standards document. One of the reasons for adopting this style was to improve readability and memorability of options. It's easy to get confused between a --long-option and short-option bundling. If a program supports both, you might find something where all the following do the same thing:
Code:
program --verbose --yes
program --verbose -y
program -v --yes
program -v -y
program -vy
Note that the --yes is distinguishable from -yes only by the double hyphen. -yes would presumably be interpreted as a bundled version of -y -e -s, if those options existed.
Quote:
Originally Posted by babu198649
is it necessary to use the first occuring option before using the next.
|
Generally not for options. For arguments which are not options (i.e. do not have a - or -- at the start) the order often
is important. For example, the cp (file copy) command, these two commands do the same thing:
Code:
cp -i -p somefile anotherfile
cp -p -i somefile anotherfile
But these two commands do a different thing - one which you probably don't want to get wrong:
Code:
cp -i -p somefile anotherfile
cp -i -p anotherfile somefile
Processing the command line options is the job of the program itself, and as such it is the responsibility of the programmer to do so in a manner which is consistent with other programs. There is the odd program which breaks the accepted conventions. In my experience these tend to be the same ones that do not provide manual pages, or other good documentation, and they are often annoying to use.