Passing options like -l or --word to commands, or parsing them in scripts.
Use this tag for questions about options for shell commands: passing them and parsing them.
There are three common variants of option syntax; different commands use different syntax.
- POSIX: This is the traditional Unix style. Options consists of a
-(dash a.k.a. minus) followed by a single letter. If-is followed by multiple letters, each letter is an option (this is called bundling). Example:ls -lais equivalent tols -l -a.
An option can take an argument, which is either in the next word or glued to the option. Example:sort -st:is equivalent tosort -s -t :. - GNU: in addition to the POSIX syntax, options can start with
--and consist of multiple letters. Arguments are either given after a=or in the next word. Example:sort --stable --field-separator=:is equivalent tosort --stable --field-separator :. - Multi-letter: an option consists of a
-followed by more characters (usually letters and dashes). If there is an argument, it is in the next word. Example:xterm -name foo -e foo