Mac OS find files using regex

Posted: 02/12/14

An image of Mac OS find files using regex

If you want to find files of a certain type (extension) within a directory, and nested directories, the following Terminal bash command works perfectly on the latest versions of OSX:

find -E . -iregex '.*\.(type1|type2|type3)' -exec commandYouWantToExcuteOnTheFile {} \;

This will match anything.type1, anything.type2, anything.type3

Replace "commandYouWantToExecuteOnTheFile" with the executable and attributes you want to run against each file found.

{} is the notation for the selected file, so place this wherever your required executable expects the file path or -input attribute to be.

Keywords for this post: mac, osx, find, bash, script, files, type, regex, terminal