Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to exclude some directories from the results of /usr/libexec/locate.updatedb by editing /etc/locate.rc. Unfortunately if I edit locate.rc locate.updatedb runs forever and does not actually terminate -- I have to kill it, and then the database for locate is an empty file.

Any ideas on why locate.rc is not respected?

I'm on ML (OS X 10.8), using bash from Macports (bash 4.2.37(2)-release), and my locate.rc reads:

# /etc/locate.rc -  command script for updatedb(8)
# $FreeBSD: src/usr.bin/locate/locate/locate.rc,v 1.9 2005/08/22 08:22:48 cperciva Exp $

# All commented values are the defaults
# temp directory

# the actual database

# directories to be put in the database

# directories unwanted in output
PRUNEPATHS="/tmp /var/tmp /Users/me/.vim /Users/me/.cups /Users/me/tmp"

# filesystems allowed. Beware: a non-listed filesystem will be pruned
# and if the SEARCHPATHS starts in such a filesystem locate will build
# an empty database.
# be careful if you add 'nfs'
#FILESYSTEMS="hfs ufs"
share|improve this question

Have you tried the terminal command:

/usr/libexec/locate.updatedb --prune-path="<path>"
share|improve this answer
Unfortunately, it utterly ignores the --prune-path part, it does index the directories it's meant to ignore – user1256923 Aug 13 '12 at 10:08
In addition, the answer does not explain while locate.updatedb does not respect /etc/locaterc – user1256923 Aug 19 '12 at 16:46
Sorry that I cannot explain why locate.updatedb doesn't work like it used to - you'll have to ask Apple that question! locate.updatedb is just a script, however. Have you tried editing the file to include the paths you want excluded? The line which needs editing is this one: : ${PRUNEPATHS:="/private/tmp /private/var/folders /private/var/tmp */Backups.backupdb"} # unwanted directories – IconDaemon Aug 20 '12 at 13:06

I am not sure that you must use 'locate' command, or not. If you can use an alternative command, you actually can use spotlight command 'mdfind' in terminal. You can set the folders to exclude folders in spotlight preference pane, and then type 'mdfind -name' to find files. And make an alias for 'mdfind -name' to 'locate' in your bash or zsh setting could save you a few strokes.

share|improve this answer
mdfind doesn't work for /usr, /Library etc. – patrix Aug 16 '12 at 4:42
Spotlight should index most files in /Library/ and /usr/, but not necessarily their contents. And it does exclude other files. – user495470 Aug 16 '12 at 17:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.