Write this:
search() {
find "$1" -type f \( -true \
-o -name "*$2*" \
-o -name "*$3*" \
-o -name "*$4*" \
-o -name "*$5*" \
-o -name "*$6*" \
-o -name "*$7*" \
-o -name "*$8*" \
-o -name "*$9*" \
-o -name "*$10*" \
\)
}
- As @chepner points out, the single quotes prevent the parameters from expanding. Use double quotes.
- The
egrep
will create a line-based match result, which is less precise than the above. It's also slower.
If the above statements are not exactly what you need, keep in mind GNU find has regular expression predicates in addition to -name's pattern matching. There's no need to pipe to grep
. You can expand the above function to take an unlimited number of arguments by constructing the arguments to find
, such as in this answer.