How to use the locate command on Mac
My name is Ito, and I'm an infrastructure engineer who uses both Mac and Windows.
Speaking of Mac's file search function, it's Spotlight search!
However, with just the Spotlight function, I can't find configuration files that are deep in the hierarchy...
The "locate" command can be used in such cases. You can create an index database of files and search files quickly.
Although it is necessary to create and update the file index database, it is much faster compared to the find command.
By the way, the find command searches and displays files in real time, so it's not that fast.
So let's use the locate command to find the file! When I thought about it, I couldn't immediately use the locate command on Mac. .
This time, we will show you how to use the locate command on a Mac.
locate on Mac
This is how I got angry.
Well, I thought it was because I hadn't used the updatedb command, but it said that there was no updatedb command. . .
Then, read again what is written in the locate command.
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.
Simply translated...
Note! locate database does not exist.
To create a database, execute the following command.sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
That's what I mean. . It wasn't the updatedb command.
So, let's execute the command as instructed.
I got worried because it was over in an instant, so I tried running it again...
It seems like a database is being created behind the scenes.
It depends on the capacity of your Mac, so I can't say for sure, but try using the locate command again after about 5 minutes.
The locate command returns results.
Isn't there rsyncd.conf? I'll write another article about this.
Now you can find library files that cannot be found even with the Spotlight feature!