我在 Mac(Catalina,10.15.7)上工作,想使用 -command locate <...>
。输入后,locate ...
它建议我执行以下操作,我照做了。
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.
创建数据库后,我想执行 -command locate
。这没有按预期工作。相反,出现了以下内容:
locate: locate database header corrupt, bigram char outside 0, 32-127: -1
我该怎么做才能解决这个问题?非常感谢您的帮助。
答案1
您可以尝试删除(或移动)locatedb 文件,例如,mv /var/db/locate.database /var/db/locate.database.backup
然后使用从头开始重新生成数据库/usr/libexec/locate.updatedb
。您将需要使用sudo
以下命令:
sudo mv /var/db/locate.database /var/db/locate.database.backup
sudo /usr/libexec/locate.updatedb