mac中使用locate遇到的问题

系统版本:MacOS High Sierra(10.13.6)

问题起因:

我想要快速查找nginx.conf文件所在的地址,根据查询,发现可以用locate工具。于是操作如下:

locate nginx.conf

得到如下警告1:

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.

解决办法:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

继续使用发现,上面操作没有生效。解决办法:更新库

sudo /usr/libexec/locate.updatedb

上面操作有点耗时,我用ctrl+c打断了操作,再使用locate命令,从而引发了下面警告:

locate: locate database header corrupt, bigram char outside 0

解决办法:继续更新库的操作,等待这个操作正确完成即可。

参考:

Problems with locate after Homebrew update on Mac

Mac 下locate命令使用问题WARNING: The locate database (/var/db/locate.database) does not exist.

nginx快速查看配置文件的方法

猜你喜欢

转载自blog.csdn.net/u010682774/article/details/111197068