2.11 Combining Primaries With Operators
Operators build a complex expression from tests and actions.
The operators are, in order of decreasing precedence:
- Force precedence. True if expr is true.
- True if expr is false. In some shells, it is necessary to
protect the ‘!’ from shell interpretation by quoting it.
- expr1 expr2
- And; expr2 is not evaluated if expr1 is false.
- Or; expr2 is not evaluated if expr1 is true.
- List; both expr1 and expr2 are always evaluated. True if
expr2 is true. The value of expr1 is discarded. This
operator lets you do multiple independent operations on one traversal,
without depending on whether other operations succeeded. The two
operations expr1 and expr2 are not always fully
independent, since expr1 might have side effects like touching
or deleting files, or it might use ‘-prune’ which would also
find searches the directory tree rooted at each file name by
evaluating the expression from left to right, according to the rules
of precedence, until the outcome is known (the left hand side is false
for ‘-and’, true for ‘-or’), at which point
moves on to the next file name.
There are two other tests that can be useful in complex expressions:
— Test: -true
— Test: -false