Command Line Arguments and Options – Official Standards

command linegnustandard

I came across a confusing variation in the understanding what options and arguments are with regard to the syntax of commands.

For instance, I encountered definitions like:

  • command -a -b -c d e f

    some differ between -a -b -c, call them options or switches and d e f by calling them arguments.

  • command -a -b -c d e f

    some, for instance a bash manual, call all -a -b -c d e f arguments and explains, that all of them are accessible from a script by $1 $2 $3 $4 $5 $6 respectively.

  • command -a b=c

    some call -a an option, b an argument and c the value, but others mix them like in the first two points, in one variety calling all -a b c arguments.

Those three versions are only examples for a plethora of different calling varieties, I do not even know how to list them all, but I noticed that for sure there is no fixed naming convention.

Or at least, there is no standardised naming convention I know about, because I came across different random sources, but even among official Linux and GNU affiliated sites or manuals I could met this inconsistency.

Is there a unquestionable official naming scheme I can refer to?

Best Answer

Adapted from the POSIX standard's "Utility Argument Syntax" section:

utility_name [-a] [-b] [-c option_argument]
             [-d|-e] [-f[option_argument]] [operand...]

The utility in the example is named utility_name. It is followed by options, option-arguments, and operands.

The arguments that consist of - characters and single letters or digits, such as a, are known as options (or, historically, flags). Certain options are followed by an option-argument, as shown with [-c option_argument]. The arguments following the last options and option-arguments are named operands.

The standard also defines "argument" as

In the shell command language, a parameter passed to a utility as the equivalent of a single string in the argv array created by one of the exec functions. An argument is one of the options, option-arguments, or operands following the command name.


All things after the utility_name on the command line are the utility's arguments, and they all show up in the positional parameters if it's a shell script. The terms option, option-argument, and operand are more specific names for these arguments on the command line.

"Flag" and "switch" are common synonyms to "option".

In the case of

utility -a b=c
  • -a and b=c are arguments,
  • -a is an option if the utility recognises it as such (the ln utility has no -x option, so -x is not an option to ln, strictly speaking, and ln -x would trigger a diagnostic message),
  • b=c is an option-argument if the -a option takes an argument, otherwise it's an operand,
  • b and c are not options, option-arguments and not operands in themselves.

As you notice from my text above, working from the synopsis of a utility (as given by the manual of the utility) would have been easier than trying to decode a generic command typed on the command line. The manual will clearly state what options takes option-arguments and what arguments are operands etc.

To call c a "value" is IMHO perfectly ok. It's not a something that is standardised, but very few would misunderstand you if you say "c is the value given to b". It would be clear from the context of the utility in question.

For example

$ awk -v var="d" '...' data.in

Anyone who knows about awk would say that -v var="d" means "the awk variable var is assigned the value d on the command line".

Related Question