Unixコマンド/locate の変更点


*&size(15){''locate''}; [#o8f544f2]

**''機能'' [#g0922092]
locateコマンドは、Unixにてファイルやディレクトリをデータベースとして記録しておき。~
そのデータベースから検索します。
find と違い、locate はその場でディレクトリを検索するのではないので検索時間がかからない。~
欠点は、データベースが更新された後にファイルの移動などをした場合、その情報がデータベースに反映されないことである~
FreeBSD の場合は、/etc/periodic/weekly/310.locate というスクリプトが週に1回実行され、~
その中で /usr/libexec/locate.updatedb が呼ばれて/var/db/locate.database が更新される。~
つまり週に一度だけデータベースが更新されることになる。~
なお、/etc/periodic/ を実行するのは cron デーモンである。~
※Linuxの場合1日1回データベースの更新が行われる。~

**''構文'' [#ycddee71]
locat [オプション] パターン

**''オプション'' [#dbb3b9b4]
 -d データベース名  デフォルトのデータベースではなく検索対象データベースを指定

**''コマンド例''~ [#kc6f739e]
■xf86と名前のつくファイルを検索する。~
ちなみにfinedだと「find / -name '*xf86*'」
 root@vaio# locate xf86
 /usr/ports/audio/xmms-xf86audio
 /usr/ports/audio/xmms-xf86audio/Makefile
 /usr/ports/audio/xmms-xf86audio/distinfo
 /usr/ports/audio/xmms-xf86audio/files
 /usr/ports/audio/xmms-xf86audio/files/patch-Makefile
 /usr/ports/audio/xmms-xf86audio/files/patch-xf86audio.c
 /usr/ports/audio/xmms-xf86audio/pkg-descr
 /usr/ports/audio/xmms-xf86audio/pkg-plist
 /usr/ports/emulators/xmame/files/patch-src-unix-video-drivers-xf86_dga1.c
 /usr/ports/emulators/xmame/files/patch-src-unix-video-drivers-xf86_dga2.c
 /usr/ports/graphics/dri/files/patch-xf86drm.h
 /usr/ports/korean/hanterm-xf86
 /usr/ports/korean/hanterm-xf86/Makefile
 /usr/ports/korean/hanterm-xf86/distinfo
 /usr/ports/korean/hanterm-xf86/files
 /usr/ports/korean/hanterm-xf86/files/defaultfont.ad
 /usr/ports/korean/hanterm-xf86/files/patch-configure
 /usr/ports/korean/hanterm-xf86/files/patch-makefile_in
 /usr/ports/korean/hanterm-xf86/pkg-descr
 /usr/ports/korean/hanterm-xf86/pkg-plist
 ・
 ・
 ・
 ・

**更新スクリプト [#s9d3c87f]
 /etc/periodic/weekly/310.locate
 # /etc/periodic/weekly/310.locate

**更新コマンド(FreeBSD) [#m99f0c00]
 # echo /usr/libexec/locate.updatedb |su -fm nobody

**更新コマンド(Linux) [#m99f0c00]
 # updatedb