I am trying to understand info who
but completly fail at the term »non-option argument«. Can someone please explain this term to me in simple words or an example?
UPDATE: from ' info who' :
If given no non-option arguments, `who' prints the following
information for each user currently logged on: login name, terminal
line, login time, and remote hostname or X display.If given one non-option argument,
who' uses that instead of a
/var/run/utmp' or
default system-maintained file (often/etc/utmp')
/var/log/wtmp' is commonly given as an argument to `who' to look at
as the name of the file containing the record of users logged on.
who has previously logged on.If given two non-option arguments,
who' prints only the entry for
am i', as
the user running it (determined from its standard input), preceded by
the hostname. Traditionally, the two arguments given are
in `who am i'.
I [thought to] know the difference between an argument and an option, but this [again] nixes a lot.
Best Answer
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.“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-
(whichwho
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:
foo -obar
:bar
is the argument to the single-letter option-o
.foo --option=bar
.foo -o bar
orfoo --option bar
. If the option-o
(or--option
) takes an argument, thenbar
is the argument of the option-o
(or--option
). If-o
(or--option
) does not take an argument thenbar
is an operand.Here's a longer example:
-n
is an option,3
is an argument to the option-n
, andmyfile
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.