bashmacosdocumentlocate

Locate command can't find anything inside Documents folder on mac


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

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

I then try and search for something inside my Documents folder

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

I then try another random folder:

Documents $ cd ..
~ $ 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
~ $ 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.


Solution

  • 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).