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 hyphen can be followed by multiple single-character flags. A double hyphen prefixes a single, multicharacter option.
Consider this example:
In this example,
Now consider another example:
In this case,
|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,