Faster Search for Mac OS X using Terminal

Using Spotlight for file searches can be fast (even faster if you are using SSD) and it is also speedy to use the search field in the upper right corner of the Finder window, but there is an even faster way of searching through the files on your hard drive using Terminal.

In Terminal, you can use the Unix Command locate, this command relies on creating an index database for performing searches, much as Spotlight does, but the searches are much more efficient without the added operating system processes. However, when using this command, you must type the full filename and extension in order for it to find the queried file.

To set up an index database for Terminal in order to make locate command searches, simply type this command in Terminal:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

It will take some time to build an index, but note that once this process is done, the index file will not include any files added afterwards unless you perform this command again to include the new files.

In addition to using locate, you can also use the command mdfind. This Terminal command is another form of a Spotlight search, which uses the central metadata store without you having to build a separate index file.

The command mdfind can be used in various ways that the command locate cannot be used. You can find a list of uses for mdfind at Apple's Mac OS X Developer Library.

0 Comments:

Post a Comment