What's the equivalent of Linux's updatedb command for the Mac?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Fantascape Looping
--
Chapters
00:00 What'S The Equivalent Of Linux'S Updatedb Command For The Mac?
00:20 Accepted Answer Score 394
00:34 Answer 2 Score 25
01:12 Answer 3 Score 108
01:26 Answer 4 Score 5
01:45 Thank you
--
Full question
https://superuser.com/questions/109590/w...
--
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.