locate

From NetBSD Wiki

Jump to: navigation, search

locate -- find files

locate(1) searches a database for all pathnames which match the specified pattern. The database is recomputed periodically, and contains the pathnames of all files which are publicly accessible.

Contents

Finding Files

To find a file just enter the filename or parts of the filename or pathname. All files matching your search pattern will be displayed.

% locate helloworld.c
/home/john/codesnippets/helloworld.c

Can be used for partials as well:

% locate \.jpg
/home/john/images/image1.jpg
/home/john/images/image2.jpg
/var/www/htdocs/img/pic1.jpg

Updating the Database

To get best results the locate database should be updated daily via cron. To update the database manually, run locate.updatedb in /usr/libexec

% /usr/libexec/locate.updatedb &

See also

View source code (Please report any bugs or suggestions here).

Personal tools