The syntax for
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]
In your case
-type are both expressions. So, there is no problem with using one before another.
GNU find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence (see section OPERATORS), until the outcome is known (the left hand side is false for and operations, true for or),at which point find moves on to the next file name.
find -type d -iname "*manifest*": It first test for directory only and then test the name matches with
find -iname "*manifest*" -type d: It first test the name matches with
"*manifest*" and then test directory only.
And executing different orders may result in performance difference for a huge finding.
And in order to optimize,
find provides Optimization options as follows:
Enables query optimisation. The find program reorders tests to speed up execution while preserving
the overall effect; that is, predicates with side effects are not reordered relative to each other.
The optimisations performed at each optimisation level are as follows.
0 Equivalent to optimisation level 1.
1 This is the default optimisation level and corresponds to the traditional behaviour. Expres‐
sions are reordered so that tests based only on the names of files (for example -name and
-regex) are performed first.
2 Any -type or -xtype tests are performed after any tests based only on the names of files, but
before any tests that require information from the inode. On many modern versions of Unix, file
types are returned by readdir() and so these predicates are faster to evaluate than predicates
which need to stat the file first.
3 At this optimisation level, the full cost-based query optimiser is enabled. The order of tests
is modified so that cheap (i.e. fast) tests are performed first and more expensive ones are per‐
formed later, if necessary. Within each cost band, predicates are evaluated earlier or later
according to whether they are likely to succeed or not. For -o, predicates which are likely to
succeed are evaluated earlier, and for -a, predicates which are likely to fail are evaluated
In order to analyse the optimization with your current command-line syntax, you can send it for debugging with
-D and get optimized command-line.
opt Prints diagnostic information relating to the optimisation of the expression tree;
find -D opt -type d -iname "*manifest*" outputs:
Optimized command line:
( -iname *manifest* [0.8] -a [0.4] [need type] -type d [0.4] )