Macでlocateを利用可能にする

  • 作成日 2019.10.01
  • 更新日 2020.07.20
  • mac
Macでlocateを利用可能にする

locateコマンド、デフォルトでは利用できなかったので利用できるようにする。DBを利用しているのでデータの肥大化は注意して下さい。

環境

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.5
BuildVersion: 18F132

locateコマンド実行

## locate実行
locate filename

<実行結果>
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

## locate再度実行
locate filename

<実行結果>
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.

同一のエラーが発生。どうもDBの更新が必要らしい

## DB更新
sudo /usr/libexec/locate.updatedb

## locate実行
locate filename

以上で、実行可能にはなった