Not particularly elegant but with basic find
:
$ ls
DATtestTF90 EB80test POSPO02test UI11
$ find . -name "*DAT*" -prune -o -name "*test*" \( -name "*EB80*" -o -name "*TF90*" -o -name "*UI11*" -o -name "*POSPO02*" \) -print
./POSPO02test
./EB80test
The arguments to find can be understood as:
-- If the name matches "*DAT*"
stop! (-prune
) and proceed no further (see also: What does -prune option in find do?)
-- Otherwise, (-o
), if the name matches "*test*"
AND the name contains any one of the given patterns, output the name (-print
)
The parentheses work like you'd expect in a typical programming language. By default any two predicates have an AND relation, but this can be overidden with -o
to give an OR relationship. The parens, in the words of the man page, are used to "Force precedence", again as I'm sure your used to in other languages. Hence you can read the second part of the find as
name == "*test*" AND (name=="*EB80*" OR name=="*TF90*" OR name=="*UI11*" OR name=="*POSPO02*")
Note that because the parentheses have meaning for the shell, they need to be escaped so that find receives them in tact.