Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to exclude some Windows folders on an NTFS mount from being indexed by locate. I'm familiar with the PRUNEPATHS syntax in /etc/updatedb.conf. It is a white-space separated list of directory names.

My problem is that I want to exclude directories that contain white space themselves (e.g. Program Files (x86)).

I tried backslash escapes but that didn't work.

share|improve this question
1  
Which locate implementation you have? Some locate's updatedb is a shell script. In that case see how it uses PRUNEPATHS, that may lead to a workaround. –  manatwork Oct 17 '11 at 8:20
    
I use locate (GNU findutils) 4.4.2. Its updatedb is indeed a shell script (/usr/bin/updatedb.findutils). I'll see what I can do from there. Thanks. –  lmichelbacher Oct 17 '11 at 13:41

1 Answer 1

up vote 4 down vote accepted

In updatedb.sh line 175 gives a hint:

PRUNEREGEX=`echo $PRUNEPATHS|sed -e 's,^,\\\(^,' -e 's, ,$\\\)\\\|\\\(^,g' -e 's,$,$\\\),'`

There the $PRUNEPATHS is handled like plain text, the ' ' characters are replaced and no escaping is possible.

To ensure the space survives that line 175, you must denote it without explicitly mentioning it. The best way I know is to use \s, which means a whitespace character:

PRUNEPATHS='/path/to/Program\sFiles\s(x86)'

(That will also include tab and newline characters, but in this case will be fine for you.)

Another way is to set $PRUNEREGEX directly, as updatedb would do in line 175:

PRUNEREGEX='\(^/path/to/Program Files (x86)$\)'

There you separate multiple paths with \|, so space is not an issue anymore:

PRUNEREGEX='\(^/path/to/Program Files (x86)$\)\|\(^/foo/bar$\)'
share|improve this answer
    
The \s trick works but only with the --prunepaths option of the script not whe put in the conf file. I'll probably make my own PRUNEREGEX. Thanks. –  lmichelbacher Oct 17 '11 at 16:35
    
Honestly I only tested it with command line parameter and environment variable. Actually I was unable to find any evidence that updatedb uses /etc/updatedb.conf. –  manatwork Oct 17 '11 at 17:05

Your Answer

 
discard

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.