I'm new to working in the shell and the usage of these commands seems arbitrary. Is there a reason one flag has a single dash and another might have a double dash?
A single dash can be followed by multiple single character flags. A double dash prefixes a single, multicharacter option. For example:
That is three different options: c, z, and f. Compared to:
The double dash makes disambiguates whether it is "exclude" or e, x, c, l, u, d, e combined.
|show 4 more comments|
It all depends on the program. Usually "-" is used for 'short' options (one-letter, -h), and "--" is used for "long"(er) options (--help).
Short options can usually be combined (so "-h -a" is same as "-ha")
It's really a convention. However, it can aid parsers to know more efficiently about options passed to the program.
Besides, there are neat utilities that can help parsing these commands, such as
It is nice, for we can have multiple short options combined, as other answers say, like
If there was a "lisa" argument for
In fact, you could write
There are also programs that don't obey this convention. Most notably for my sight,