Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create a customized user-centric locate database' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a customized user-centric locate database
Authored by: CarlRJ on Apr 08, '08 11:08:16AM

Interesting approach, but you could skip steps 1 and 2 (and eliminate the overhead of the cron job running the extra process to build a duplicate-but-smaller locate database), and simply replace step 3's alias with:

function llocate { locate $* | egrep "^$HOME/"; }

That'll filter the 60,000ish lines returned for ".doc" through grep, returning the 584 that start with /Users/your_name/.

That said, I normally disable the weekly run of the Apple-supplied locate.updatedb, then install GNU findutils under /usr/local (I prefer GNU's find, xargs, and locate over BSD's), and set up /etc/daily.local so it updates the database every night (I get cranky with week-old results, and want all files locatable, rather than just those visible to user "nobody", since I'm the only user on the system). If I want up-to-the-minute results, there's always find or Spotlight.



[ Reply to This | # ]
Create a customized user-centric locate database
Authored by: avn on Apr 08, '08 02:38:48PM

While the method you suggested should work as well, it requires that the original locate command be set up and running on all user directories. Mine was not set to do this by default. Likewise, because of this others can search your files quite easily. Something that you may not want.

Also, because this script is set up to run by itself, it doesn't require that you run the system-wide locatedb program, and hence can be run for very frequent updates if your user account is not bloated. I chose to run mine every hour, but one could always choose the weekly updates.



[ Reply to This | # ]
Create a customized user-centric locate database
Authored by: locateUser on Sep 19, '11 02:00:19PM

Your approach assumes that your permissions are not by default restrictive. Locate's view of the filesystem is supposed to be of the user nobody, otherwise it would override the systems permissions.



[ Reply to This | # ]