Linux: Finding files NOT matching an expression
Once I write it down, I remember it. So just for me:
„man find” is, as always your friend in such cases:
2.11 Combining Primaries With Operators
Operators build a complex expression from tests and actions. The operators are, in order of decreasing precedence:
( expr )
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 -a expr2
expr1 -and expr2
And; expr2 is not evaluated if expr1 is false.
expr1 -o expr2
expr1 -or expr2
Or; expr2 is not evaluated if expr1 is true.
expr1 , expr2
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 affect expr2.
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 find moves on to the next file name.