Shell – Is the synopsis section of the man page for the find command wrong

commandfindmanshellsyntax

So, I have been trying to get into the habit of first looking at man pages before starting to google when I forget how to run a certain command.

I was looking at the man page for the find command today and in the synopsis section it specifies the format of the command as:

SYNOPSIS
       find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]

Doesn't this show that the options must come before the path and then the expression? Or does a synopsis not specify order?

When I use find though I have to specify the path before the options like so:

find . -cmin -10 -ls

Best Answer

-cmin and -ls are predicates that are part of the expression, not options.

Note that you can mark the end of options with --, but predicates are still allowed after it.

With GNU find, which allows omitting paths:

find -- -L

Would complain about the unknown -L predicate (even though -L is a valid option which actually has a -follow equivalent predicate).

That's why while

find "$file"

like

wc "$file"

doesn't work correctly when $file starts with -.

Doing wc -- "$file" fixes it for wc (except in the special case of file='-') but not for find -- "$file". FreeBSD find has find -f "$file" for that.