I currently have a backup Jaguar partition on a separate drive and a "Previous Systems" directory from the Archive and Install of Panther that I'm not ready to get rid of yet. I use the command line tool locate often and was getting very tired of it listing everything it found from my backup drive and my Previous System directory. I'd have to either wade through the output looking for the correct items, or rig up a pipe to grep to get only the items I was looking for. I'm not sure if anyone but me has this problem, but this is how I fixed it.
I made a change in /usr/libexec/locate.updatedb so that the locate database won't store anything found in either the "/Volumes" directory (which leads to the backup drive) or the "/Previous Systems" directory.
Read the rest of the hint for the how-to...
Basically I just added -regex "/Volumes" -o and -regex "/Previous Systems" -o to the find command in the locate.updatedb script. You can manually change those dirs to anything you want and add more dirs to be ignored -- just make sure you add the "or" flag (-o) to the logic.
Find the following in /usr/libexec/locate.updatedb (around line 62):
find ${SRCHPATHS} \( ! -fstype local -o -fstype fdesc -o -fstype devfs \) -a \
-prune -o -print | \
tr '/' '\001' | \
(sort -T "$TMPDIR" -f; echo $status > $errs) | tr '\001' '/' > $filelist
and add the following code between find ${SRCHPATHS} ( and ! -fstype local:
-regex "/Volumes" -o -regex "/Previous Systems" -o \
so that the new code looks like this:
find ${SRCHPATHS} \( -regex "/Volumes" -o -regex "/Previous Systems" -o \
! -fstype local -o -fstype fdesc -o -fstype devfs \) -a \
-a -prune -o -print | \
tr '/' '\001' | \
(sort -T "$TMPDIR" -f; echo $status > $errs) | tr '\001' '/' >
Then to update your locate database right away, run the following command in Terminal:
sudo /usr/libexec/locate.updatedb
Mac OS X Hints
http://hints.macworld.com/article.php?story=20031106144210522