0

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 {} \;
  • 1
    They're not options they're operands. – don_crissti Nov 20 '18 at 22:24
  • Do you mean "optional"? What difference comes up in your interpretation? – Jeff Schaller Nov 20 '18 at 22:27
1

The find command has only two options in POSIX (-H, -L), or five in GNU (also -P, -Ddebug_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).

1

-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:

  • Tests (e.g. -name, -mtime)
  • Actions (e.g. -delete, -print)
  • Global options (e.g. -maxdepth, -depth)
  • Positional options (e.g. -follow)
  • Operators (e.g. -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.

  • Do "option" find expressions work like real options? Is that why they are called options? – Ben Nov 21 '18 at 0:28
  • What is the difference between global options and positional options? – Ben Nov 21 '18 at 0:49
  • tests and actions are find expressions evaluable to true or false. Are option find expressions evaluable, and if yes, also to true or false? – Ben Nov 21 '18 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.