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
/Applications/BetterTouchTool.app
/Users/hadoopworld/Downloads/btt0.967.zip
/Users/hadoopworld/Library/Containers/com.evernote.Evernote/Data/Library/CoreData/com.evernote.Evernote/5FEB3D01-3FEE-4E34-BE5A-576E028BC763/ENNote/_records/0/p20.ennote
/Users/hadoopworld/Library/Containers/com.evernote.Evernote/Data/Library/Application Support/Evernote/accounts/Evernote/avkashnotes/content/p20/content.html

 

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s