Re: WHERE are the docs?
On Mon, Mar 05, 2001 at 04:47:12PM -0500, xsdg wrote:
> On Mon, Mar 05, 2001 at 02:14:58PM -0400, Peter Cordes wrote:
> > locate(1) is good. It can search the whole system quickly.
> locate doesn't actually search the system. When a user runs updatedb(1?),
>a database is created of all files accessible to the user running the
>command. The locate command searches through the database. On debian
>systems, updatedb is run in cron.daily.
Yes, that's _why_ it can _effectively_ search the whole system quickly.
find takes a long time because it has to traverse the directory tree.
Locate just has to read its file where it keeps a list of every filename on
the system. This is a good thing, because sequential reads are a lot faster
than seeks and reads to scattered locations.
I don't know if findutils runs updatedb in its postinst script, but if not,
then a newly installed system won't have locate working for the first day.
After that, the only downside is that it won't find files that were
installed since last night. If a user recently installed a package, they
probably looked at its contents. Still, things aren't perfect, but locate
is a lot better than nothing.
Another useful program is glimpse. I haven't used it, but it's supposed to
make a (quickly) searchable database of the contents of all text files. It
also only runs periodically.
#define X(x,y) x##y
Peter Cordes ; e-mail: X(email@example.com. , ns.ca)
"The gods confound the man who first found out how to distinguish the hours!
Confound him, too, who in this place set up a sundial, to cut and hack
my day so wretchedly into small pieces!" -- Plautus, 200 BCE