I see in the comments that you found out how to escape it with GNU basic regexes via the nonstandard flag find -regex RE
, but you can also specify a type of regex that supports it without any escapes, making it a bit more legible:
In GNU findutils (Linux), use -regextype posix-extended
:
find . -regextype posix-extended -regex '.*\.(sh|ini|conf|vhost|xml|php)$' | …
In BSD find (FreeBSD find or Mac OS X find), use -E
:
find . -E -regex '.*\.(sh|ini|conf|vhost|xml|php)$' | …
The POSIX spec for find does not support regular expressions at all, but it does support wildcard globbing and -o
(for "or"), so you could be fully portable with this verbose monster:
find . -name '*.sh' -o -name '*.ini' -o -name '*.conf' \
-o -name '*.vhost' -o -name '*.xml' -o -name '*.php' | …
Be sure those globs are quoted, otherwise the shell will expand them prematurely and you'll get syntax errors (since e.g. find -name a.sh b.sh …
doesn't insert a -o -name
between the two matched files and it won't expand to files in subdirectories).
I'm also guessing you want -iregex
or -iname
rather than -regex
or -name
so the search is case-insensitive.