Are -name
and -exec
options or non-option arguments of find
? They look like short options, and they are called find expressions, if I am not mistaken. For example,
find . -name "*.txt" -exec echo {} \;
Are -name
and -exec
options or non-option arguments of find
? They look like short options, and they are called find expressions, if I am not mistaken. For example,
find . -name "*.txt" -exec echo {} \;
-name
, -exec
, -print
etc. are not option to the find
utility but operands. An operand is
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.
(from the POSIX definitions), i.e. a non-option that tells the utility what to do (as the file
in the command rm file
which tells rm
what file to delete).
The POSIX standard description of the find
utility calls these operands primaries and this is also what they are called on BSD systems.
In the GNU find
manual, they are called expressions and are divided into groups depending on their use:
-name
, -mtime
)-delete
, -print
)-maxdepth
, -depth
)-follow
)-not
, -and
)The POSIX standard find
only has two real options, -H
and -L
. These has to do with how symbolic links are to be handled.
The POSIX standard does not define any multi-character option or "long option" for any utility. This does no preclude implementations from adding long options though, and GNU utilities in particular are well known for adding expressive long options for extended convenience features.
The find
command has only two options in POSIX (-H
, -L
), or five in GNU (also -P
, -D
debug_opt
, -O#
). All other arguments are not options, and thus are non-option arguments.
Notably, options to find
precede the paths, while all find expressions should follow them: find [option...] path... [expression...]
. (GNU find has some additional primaries that it also calls "options" sometimes, like -maxdepth
; they're not true options, appearing inside the expression part, but I suppose the warning messages are more comprehensible if they call them that way).