Server Fault is a question and answer site for system and network administrators. 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'd like to configure locate to always exclude specific file types.

For example, I would like to exclude ".pyc" ".class" "~" etc.

share|improve this question
up vote 3 down vote accepted

This is a duplicate question from

In updatedb.conf, uncomment the PRUNENAMES line and add the extension .pyc. On my Ubuntu system by default it reads:

# PRUNENAMES=".git .bzr .hg .svn"

Change it to

PRUNENAMES=".git .bzr .hg .svn .pyc"
share|improve this answer

look at /etc/updatedb.conf

share|improve this answer

Hideous hack though it may be, you could always use grep:

locate foo | grep -v ".pyc$" | grep -v ".class$"

and chain as necessary.

share|improve this answer

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.