On a Mac OS X system, you can use the
mdfindcommand to locate files on the system from a command line interface, e.g., from a shell prompt that you may obtain by running the Terminal program, which is located in
Applications/Utilities. You can specify the name of the file using the
$ mdfind -name Waterfalls.mp3 /Users/jdoe/Music/iTunes/iTunes Media/Music/Bob Weir/Relax With Soothing Waterfalls/01 Soothing Waterfalls.mp3 /Users/jdoe/Downloads/Waterfalls.mp3
You can specify just part of the file name and the search is not case specific, i.e., "waterfall" and "Waterfall" are deemed identical.
$ mdfind -name waterfall /Users/jdoe/Downloads/Waterfalls.mp3 /Users/jdoe/Music/iTunes/iTunes Media/Music/Bob Weir/Relax With Soothing Waterfalls/01 Soothing Waterfalls.mp3 /Users/jdoe/Music/iTunes/iTunes Media/Music/Bob Weir/Relax With Soothing Waterfalls /Library/Desktop Pictures/Eagle & Waterfall.jpg
As shown in the above example, directories whose names contain the string on which you are performing the search, i.e., "waterfall" in the above case, will also be returned.
If you just want a count of files and directories containing a
particular string, such as "waterfall" in the name, you can add the
$ mdfind -count -name waterfall 4
If you want to limit the search to a particular directory you can use
$ mdfind -name waterfall -onlyin "/Library/Desktop Pictures/" /Library/Desktop Pictures/Eagle & Waterfall.jpg