Pergunta

As it says in the description. I first check our database is up to date

mh547:bin crashandburn4$ sudo /usr/libexec/locate.updatedb
Password:       #password entered and function executed without errors

I then try and search for something inside my Documents folder

mh547:bin crashandburn4$ cd ~/Documents/
mh547:Documents crashandburn4$ ls
    Mamp_workspace/                         Scenarios.docx                          gc01/
mh547:Documents crashandburn4$ locate Scenarios.docx    #nothing returned

I then try another random folder:

mh547:Documents crashandburn4$ cd ..
mh547:~ crashandburn4$ ls
    Applications/                Movies/                      drawable/                    untitled-2.pdf
    Desktop/                     Music/                       drawable-xhdpi/              untitled-2.synctex.gz
    Documents/                   Pictures/                    dwhelper/                    untitled-2.tex
    Downloads/                   Public/                      linux_ssh*                   website-terminal-copy-paste
    Dropbox/                     Samsung/                     scripts/                     workspace/
    Google Drive/                Sites/                       untitled-2.aux               workspace_copy_to_linux*
    Library/                     android-sdks/                untitled-2.log
mh547:~ crashandburn4$ locate website-terminal-copy-paste 
/Users/crashandburn4/website-terminal-copy-paste #correct result returned

can anyone help me? I've been stuck on this for a good half hour or so.

Foi útil?

Solução

As pointed out by plundra, that's because the locate OSX ships with is old and crippled and doesn't index and/or report files which are not readable by nobody, even when run as root. What you can do though is either install homebrew and then GNU locate, or, as suggested here use mdfind -name instead (I don't have an OSX box at hand to test this).

Outras dicas

It's because your Documents-folder isn't world readable, which is a good thing, specially on shared systems.

The BUGS section of the locate(1) man-page explains it:

The locate database is typically built by user ''nobody'' and the locate.updatedb(8) utility skips directories which are not readable for user ''nobody'', group ''nobody'', or world. For example, if your HOME directory is not world-readable, none of your files are in the database.

Try running ls -ld ~/Documents and you'll see the permissions. Wikipedia have an article on Unix permissions if you are unfamiliar with these.

You can do sudo ln -s /usr/libexec/locate.updatedb /usr/local/bin/updatedb to make the updatedb command available

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top