Tuesday, May 10, 2011

Running spotlight from your Mac terminal window

A colleague just showed me this most excellent little command you can add to your .profile on the Mac to do Spotlight-indexed searches from the command line. Very nice.

function slocate() {
mdfind "kMDItemDisplayName == '$@'wc";
}

config[master]% time slocate my.cnf
/private/etc/my.cnf
/opt/local/var/macports/sources/rsync.macports.org/release/ports/databases/mysql4/files/my.cnf
real 0m0.018s
user 0m0.006s
sys 0m0.006s

No comments: