A (slightly) simpler command-line Spotlight search
Erica mentioned mdfind a little while ago. It's not a brand new tool, but there hasn't been a great deal of discussion surrounding it. For shell scripters and Terminal junkies, it's a goldmine of search goodness that can make you never want to key out
find . -name "letsgogetcoffeewhilewewait.rb" or even
locate didcronupdatethedb.yet again.
There are two
mdfind options mentioned at Mac OS X Hints that are worth a mention, one found only in the man page, and one found only in the usage info. The former being "-interpret", which allows the advanced Spotlight query syntax to be used on the command line as if typed into the Spotlight window, turning
mdfind "kMDItemContentType == 'public.jpeg'" into
mdfind -interpret "kind:jpeg". Its opposing force would be "-literal", which forces a literal interpretation of the query string. Any qualified Spotlight query should be usable with "-interpret", so go ahead with
mdfind -interpret "kind:image flash:1 modified:<=1/1/08 ex-girlfriend" to find those late-night pictures of last year's special someone. That would take a lot of metadata work to pull off without "-interpret".
The second option mentioned isn't in the man page, but you'll see it in the usage info if you run
mdfind with no parameters. It's the "-s" option that loads saved searches. It will look in
~/Library/Saved Searches unless a path is specified. So you can save a search in Spotlight called "PDFs from yesterday" and run
mdfind -s "PDFs from yesterday" to launch the same search at the command line. See, I had to throw a "normal" search in there to keep you on your toes.
Terminal jockeys can mix these up with a few pipes, stir in some perl and sprinkle in a little awk to get some really great Spotlight soufflé. Of course, if you don't like the command line and you're still reading this, you're a downright hardy trooper and I commend you. Go have a cup of coffee, you deserve it.[via Mac OS X Hints]
Subscribe to Newsletter
Software Updatesmore updates
- Dropbox adds file/folder renaming and Office document editing to iOS app
- Vizzywig 8xHD price tag now a very affordable $49.99
- Automatic targets teen drivers with License+ service
- Dropbox adds support for TouchID
- YouTube for iOS gets updated with full support for iPhone 6 and 6 Plus
- iOS 8.0.1 update now available (Updated -- Don't update!)