The terminology is not completely fixed, so different documentation uses different terms, or worse, the same terms with different meanings. The terminology in the man page you're reading is a common one. It is the one used in the POSIX standard. In a nutshell, each word after the command is an argument, and the arguments that start with -
are options.
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.
An argument to a command that is generally used as an object supplying information to a utility necessary to complete its processing. Operands generally follow the options in a command line.
An argument to a command that is generally used to specify changes in the utility's default behavior.
“Utility” is what is generally called “command” (the standard uses the word utility to avoid ambiguity with the meaning of “command” that includes the arguments or even compound shell commands).
Most commands follow the standard utility argument syntax, where options start with a -
(dash a.k.a. minus). So an option is something like -a
(short option, follows the POSIX guidelines) or --all
(long option, an extension from GNU). A non-option argument is an argument that doesn't begin with -
, or that consists solely of -
(which who
treats as a literal file name but many commands treat as meaning either standard input or standard output).
In addition, some options themselves have an argument. This argument can be passed in several ways:
- For a single-letter option, in the same argument to the utility:
foo -obar
: bar
is the argument to the single-letter option -o
.
- In the GNU long argument syntax, in the same argument, separated by an equal sign:
foo --option=bar
.
- In a separate argument:
foo -o bar
or foo --option bar
. If the option -o
(or --option
) takes an argument, then bar
is the argument of the option -o
(or --option
). If -o
(or --option
) does not take an argument then bar
is an operand.
Here's a longer example:
tail -n 3 myfile
-n
is an option, 3
is an argument to the option -n
, and myfile
is an operand.
Terminology differs, so you may find documents that use argument in the sense where POSIX uses operand. But “non-option argument” is more common than either term for this meaning.
paste -d
takes a mandatory argument.
See the man page
-d, --delimiters=LIST
reuse characters from LIST instead of TABs
This format really means
-d LIST or --delimiters=LIST
reuse characters from LIST instead of TABs
So with paste -d file1
, you're setting LIST
to file1
, and no file name is specified. And as the man page says:
With no FILE, or when FILE is -, read standard input.
With paste -ds file1
, you're setting delimiter to s
. You'd have to supply multiple files to see the effect.
Compare
$ paste <(printf 'foo\nbar\n') <(printf 'one\ntwo\n')
foo<TAB>one
bar<TAB>two
$ paste -ds <(printf 'foo\nbar\n') <(printf 'one\ntwo\n')
foosone
barstwo
Best Answer
In general, the implementation of how command-line arguments are interpreted is left completely at the discretion of the programmer.
That said, in many cases, the value of a "long" option (such as is introduced with
--option_name
) is specified with an=
between the option name and the value (i.e.--option_name=value
), whereas for single-letter options it is more customary to separate the flag and value with a space, such as-o value
, or use no separation at all (as in-oValue
).An example from the man-page of the GNU date utility:
As you can see, the value would be separated by a space from the option switch when using the "short" form (i.e.
-d
), but by an=
when using the "long" form (i.e.--date
).Edit
As pointed out by Stephen Kitt, the GNU coding standard recommends the use of
getopt
andgetopt_long
to parse command-line options. The man-page ofgetopt_long
states:So, a program using that function will accept both forms.