As much as MacOS’ Spotlight is an integral and indispensable part of my interaction with my laptop, a part of me still begrudges the “gratuitous” CPU and disk utilisation which is of course a necessary part of its operation.
However as a hardened Linux user unprepared to do without the luxury of the
locate database, my inner resource miser was further upset on discovering that these databases were not shared, and with even more irritation enabled the periodic
updatedb cron job, as was suggested by locate itself.
Whether it was SSD envy, a nagging sense of a job half-done or sheer procrastination I’m not sure, but last week I felt compelled to do away with the needless platter-spinning and found the answer far too quickly, in the form of the Spotlight shell utility
One alias later:
alias locate="mdfind -name"
and I was able to destroy the locate database, and discontinue its indexing:
launchctl stop /System/Library/LaunchDaemons/com.apple.locate.plist launchctl unload -w /System/Library/LaunchDaemons/com.apple.locate.plist
Some obligatory qualifications…
This applies largely to OS X 10.6, Snow Leopard. Leopard’s arrangement is slightly different, and I know nothing about earlier versions… And no, it doesn’t support all of locate’s arguments, but I rarely used them (apart from
-i) anyway (and don’t have any case-sensitive, indexed filesystems on the mac right now).
man mdfind provides workarounds for many of the more unusual uses of locate, and
grep provides the rest…