1

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
#TMPDIR="/tmp"

# the actual database
#FCODES="/var/db/locate.database"

# directories to be put in the database
#SEARCHPATHS="/"

# 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"
0

2 Answers 2

2

Have you tried the terminal command:

/usr/libexec/locate.updatedb --prune-path="<path>"
3
  • Unfortunately, it utterly ignores the --prune-path part, it does index the directories it's meant to ignore Aug 13, 2012 at 10:08
  • In addition, the answer does not explain while locate.updatedb does not respect /etc/locaterc Aug 19, 2012 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, 2012 at 13:06
1

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.

2
  • mdfind doesn't work for /usr, /Library etc.
    – nohillside
    Aug 16, 2012 at 4:42
  • Spotlight should index most files in /Library/ and /usr/, but not necessarily their contents. And it does exclude other files.
    – Lri
    Aug 16, 2012 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .