I came across the notion of primaries from running man find:

     All primaries which take a numeric argument allow the number to be preceded by a plus sign (``+'') or a minus sign (``-'').  A preceding plus sign means ``more than n'', a pre-
     ceding minus sign means ``less than n'' and neither means ``exactly n''.
     -depth n
             True if the depth of the file relative to the starting point of the traversal is n.

Searching POSIX documentation for "primaries" turned up no results.

Doing a little bit of exploring, it looks like primaries are different from switches and flags because they appear after the switches, flags, and main arguments:

$ find -depth 1 .
find: illegal option -- e
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
$ find . -depth 1

I'm wondering:

  • What are primaries?
  • Is there any documentation I can read about them?
  • How are they different from switches or flags?

They're the conditions/actions of find's language, the ones that the "expression" referred to in the usage line mainly consists of: -name, -type, -print, -exec etc. The term is used to separate them from the operators that only combine the primaries: !, -a, -o and the parenthesis.

I don't remember seeing that term used in other contexts than find. It's used in the POSIX specification for find and in the FreeBSD man page. GNU stands out in this, too, the documentation for GNU find (e.g. the man page) doesn't use the term, but instead divides the primaries to tests about the properties of the files, actions that do something, and options that affect how find itself works. The division seems helpful but is slightly inaccurate, since all primaries return a truth value, even the actions.

  • From man7 it looks like in GNU they are "GLOBAL OPTIONS", is this true? – mbigras May 18 '17 at 19:55
  • Right, it uses that term too for those primaries that change how find itself works. – ilkkachu May 18 '17 at 20:17

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.