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: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
like
doesn't work correctly when
$file
starts with-
.Doing
wc -- "$file"
fixes it forwc
(except in the special case offile='-'
) but not forfind -- "$file"
. FreeBSDfind
hasfind -f "$file"
for that.