Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I ran

sudo /usr/libexec/locate.updatedb

then

locate Radium3

but it returns nothing!

but

$ ls ~/Library/Containers/com.catpigstudios.Radium3/
Container.plist Data

So why doesn't locate see all the files?

Am I using this command correctly on OS X?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Try:

sudo /usr/libexec/locate.updatedb

And look config:

/etc/locate.rc the configuration file

Edited:

Post here output:

echo $LOCATE_CONFIG

And:

cat /etc/locate.rc

And:

echo $0

Update:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man1/locate.1.html#//apple_ref/doc/man/1/locate

The locate program searches a database for all pathnames which match the specified pattern. The data-base database base is recomputed periodically (usually weekly or daily), and contains the pathnames of all files which are publicly accessible.

Try mdfind instead locate

Updated2:

mdfind -name text which is more accurate. Just mdfind text gives you files that contain text as well. – David Krmpotic

mdfind -name text
share|improve this answer
    
I uncommented #SEARCHPATHS="/" in config, it didn't help. -v option doesn't seem to produce any additional output :/ –  David Krmpotic Apr 6 at 18:06
    
Give additional info for me plz. In answer "Edited" section. –  user3439968 Apr 6 at 18:28
    
pastie.org/8998774 –  David Krmpotic Apr 6 at 18:48
1  
$ ls -la /var/db/locate.database -r--r--r-- 1 nobody wheel 19463861 Apr 6 20:08 /var/db/locate.database $ locate david.jpg /Users/david/temp/david.jpg –  David Krmpotic Apr 6 at 19:51
1  
you should update your answer to mdfind -name text which is more accurate. Just mdfind text gives you files that contain text as well. –  David Krmpotic Apr 6 at 21:38

If you want to search the same database that Spotlight uses, you can use the mdfind command as an alternative (although not an exact replacement) for locate:

mdfind Radius3
share|improve this answer

Permissions may be the culprit as locate apparently cannot read files that are not world readable. See this answer by Plundra for more explanation.

The findutils package from homebrew does enable gupdatedb and glocate commands that seem to overcome some of the limitations of the builtin utilities.

share|improve this answer
    
Thank you! but now that I know about mdutil does it make sense to check out this? One use case I can think of is that I can trigger rescan manually with gupdatedb - with Spotlight not so easy or it would take longer (it also indexes files contents). Are there other advantages? –  David Krmpotic Apr 6 at 22:22
1  
Reindexing with mdutil/spotlight can take awhile for sure. updatedb is quicker for that. glocate seems to have no problem indexing system files, while I find mdfind ignores ~/Library and other system files. I definitely find I get more hits with glocate over mdfind in most circumstances. YMMV. –  VogonPoetLaureate Apr 7 at 1:26
    
ok, I'm testing this now. I think I found some problem... fist I ran sudo gupdatedb, then saved glocate Radium output. Then I ran gupdatedb and it said: /.Trashes: Permission denied, the same for some other folders. I compared the output for both and it was the same! Strange... –  David Krmpotic Apr 7 at 12:03
    
From what you're saying, you first ran sudo gupdatedb (running it as root), then you followed up later by running gupdatedb as a normal user which would not have access to the files that the root user would have access to, meaning you'd get permission denied errors. If you want a complete database of filenames for your whole system, keep running it as root. This does expose your files to other users on the system who may use the glocate command. But if you are the only user, that should be fine. –  VogonPoetLaureate Apr 11 at 15:51

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.