What's the equivalent of Linux's updatedb command for the Mac?
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Melt
--
Chapters
00:00 Question
00:29 Accepted answer (Score 384)
00:48 Answer 2 (Score 101)
01:07 Answer 3 (Score 21)
01:57 Answer 4 (Score 4)
02:18 Thank you
--
Full question
https://superuser.com/questions/109590/w...
Accepted answer links:
[locate.updatedb man page]: http://developer.apple.com/mac/library/D...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #macos #mac #locate
#avk47
ACCEPTED ANSWER
Score 394
It's locate.updatedb
on Mac.
sudo /usr/libexec/locate.updatedb
For more information see the locate.updatedb man page.
ANSWER 2
Score 108
You can do sudo ln -s /usr/libexec/locate.updatedb /usr/local/bin/updatedb
to make the updatedb
command available.
ANSWER 3
Score 25
Personally, I just installed findutils (use MacPorts or Homebrew).
Then you have GNU locate and updatedb.
updatedb won't work without sudo.
Personally I prefer to have a per user locatedb though; if you sudo other users will know the names/locations of all your files.
I have a cron job to run:
updatedb --localpaths='/Users/grogs' --output='/Users/grogs/tmp/locatedb'
And in my .zshrc .bashrc/.bashprofile:
export LOCATE_PATH="~/tmp/locatedb"
ANSWER 4
Score 5
If you run locate without first updating the database, you have a chance to see the OS's recommended way by its output.
WARNING: The locate database (/var/db/locate.database) does not exist. To create the database, run the following command: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist Please be aware that the database can take some time to generate; once the database has been created, this message will no longer appear.