Using “locate” to find stuff from Terminal

Spotlight on Mac is great but often I’m mucking around on the command line and want to find something without having to switch to spotlight and back again. locate is a great (and fast) tool which indexes your entire hard drive into a database. When searching, instead of searching the hard drive directly, it just searches its database, meaning it is blisteringly fast (sure, if you’re looking for files which have changed in the last week it’ll point to a non-existent location, but for finding that annoyingly missing php.ini file it’s great).

The locate database is rebuilt each week by periodic (which runs system functions daily, weekly and monthly). periodic is called by cron, uh, periodically. *sigh* These posts are never going to make me interesting to non-geeks.

To manually update your locate database just call the weekly periodic script:

sudo periodic weekly

Take a look at everything periodic runs by opening Terminal and taking a look inside /etc/periodic
Geeks will love you for it. I hope. *sigh*

Technorati Tags:

No comments yet. Be the first.

Leave a reply