LoginSignup
0
0

More than 5 years have passed since last update.

コマンドで検索する際、ファイル数が多い時はfindよりlocate

Last updated at Posted at 2015-02-17

locate

findみたいなの。けど検索結果吐き出すのが早い。
定期的に更新しないといけないのが面倒。
findはその場でディレクトリを検索するのでlocateより検索時間がかかってしまうらしい。

  1. 一番最初にlocateで検索しようとするとエラーが出ると思います。  以下のコマンドを打ち込んで、データベースを作成してください。  (エラーメッセージにも書いてある)
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
  1. データベース作成します。時間がかかるときもあるらしいので、数分待ちます。

  2. (これで使えない場合は)以下のコマンドでデータベースを更新する。
      定期的に以下のコマンドで更新する必要があります。

$ sudo /usr/libexec/locate.updatedb

使用例

$ locate httpd.conf
と打つと、httpd.confを検索します。

以下のように検索結果が出てきます。
/etc/apache2/httpd.conf

ファイル数が多い時は確実にlocate使ったほうが早かったのでメモ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0