10.4: Search current directory using an mdfind alias

Aug 25, '05 08:44:00AM

Contributed by: Anonymous

Tiger only hintThe Unix mdfind utility lets you search files using the Spotlight index from the Terminal. This is a great tool, but it doesn't quite replace find, which makes it very easy to search the current directory.

So here's a shell alias for a new spot command line tool which performs a Spotlight search only within the current directory:

alias spot='mdfind -onlyin `pwd`'
Example:
/Users/alf/Documents# spot run
/Users/alf/Documents/iStumbler/Bug Reports/istumbler-runaway-20050731.txt
/Users/alf/Documents...etc.
Add the alias to your .profile (or .bash_profile) file to automatically add it to every new shell.

[robg adds: If you're using tcsh, the format will be slightly different: alias spot 'mdfind -onlyin `pwd`'. I tested this one, and it works quite nicely.]

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=200508201629095