$ find -iname '*foo*' -o -iname '*bar*' -o -iname '*blah*'
that's one way to go about it, but frankly, it is result-wise similar to
shopt -s globstar ## enable recursive globbing operator **
shopt -s extglob ## enable (|) pattern lists
shopt -s nocasematch ## take a guess!
echo **/*@(foo|bar|blah)*
(but it does that without help of find).
We can very quickly build a shell script from that.
#! /bin/bash -
shopt -s globstar ## enable recursive globbing operator **
shopt -s extglob ## enable (|) pattern lists
shopt -s nullglob ## don't error if nothing matches
shopt -s nocasematch ## take a guess!
joinlist() {
IFS='|' # local"$*" IFS='|'
joins with echothe "$*"first character of IFS
pattern="**/*@(${*})*"
pattern=$(joinlistIFS= $*)# do globbing but not splitting upon unquoted expansion:
matches=( **/*@(${pattern})*$pattern )
for element in $matches;"${matches[@]}"; do
printf '%s\n' "${element}"
done
If you want to have it as a function, just put pattern=… to done in a function declaration.