find "$file_dir1" "$file_dir2" \
-name '[sS][eE][aA][rR][cC][hH][pP][aA][tT][tT][eE][rR][nN]*'
That is we replace letters like x
with the [xX]
bracket expression which matches on either x
or X
, effectively replacing a case sensitive match of lowercase x
with a case insensitive match of x
.
For some characters like ffi
where the upper-case or lower-case translation isn't a single characters, you may need to resort to things like:
find "$file_dir1" "$file_dir2" \
\( -name '*[sS][uU]ffi[xX]' -o -name '*[sS][uU]FFI[xX]' \)
as [ffiFFI]
would match on ffi
, F
or I
instead of ffi
or FFI
.
If you can guarantee your file and directory names don't contain newline characters, you could also get find
to print every file path, and use awk
to filter on the file name:
find "$file_dir1" "$file_dir2" |
awk -F/ 'tolower($NF) ~ /^searchpattern/'
(beware it's not necessarily equivalent to toupper($NF) ~ /^SEARCHPATTERN/
like in the ffi
case above or because not everybody (every locale) agrees on what the upper-case or lower-case variant of a letter is (for instance, is uppercase i
I
or İ
?); you'll also find some variations in grep -i
or other tool that do case insensive matching).
-iname
) – Jeff Schaller Feb 07 '19 at 14:54