mdfind in mac OSX : Command line search utility

mdfind is a great utility, similar to “find” in Unix/Linux however mdfind use Mac OSX spotlight index to returns to results. The command help looks like as below:


Usage: mdfind [-live] [-count] [-onlyin directory] [-name fileName | -s smartFolderName | query]

list the files matching the query
query can be an expression or a sequence of words

-live Query should stay active
-count Query only reports matching items count
-onlyin <dir> Search only within given directory
-name <name> Search on file name only
-s <name> Show contents of smart folder <name>
-0 Use NUL (“”) as a path separator, for use with xargs -0.

example: mdfind image
example: mdfind -onlyin ~ image
example: mdfind -name stdlib.h
example: mdfind “kMDItemAuthor == ‘*MyFavoriteAuthor*'”
example: mdfind -live MyFavoriteAuthor


An example of using mdfind to bettertouchtool as below:

$ mdfind bettertouchtool
/Users/hadoopworld/Library/Application Support/CrashReporter/BetterTouchTool_1DB9FB92-A7F5-5334-9193-9ABD33C6389D.plist
/Users/hadoopworld/Library/Application Support/BetterTouchTool
/Users/hadoopworld/Library/Containers/com.evernote.Evernote/Data/Library/Application Support/Evernote/accounts/Evernote/avkashnotes/content/p20/content.html




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s