what is the difference between locate and find ?

Andy Green andy at warmcat.com
Tue Nov 8 16:24:44 UTC 2005


M E Fieu wrote:

> Hi.. I tried to look for a file in a linux box using both locate and find , when using find I can
> find my file but locate cannot.  However I found sometime locate will work when I look for other
> file.  what is the difference between locate and find ?

locate uses a snapshot of your filesystem at the time its database was
created, usually nightly on a cronjob.  Find is going out and looking at
the filesystem right at the time that you run it.

If...

> [root at wa html]# locate abc.pl
> [root at wa html]# find / -name abc.pl -print
> find: /proc/21829/fd: No such file or directory
> /usr/local/abc/abc.pl
> [root at wa html]# 

...abc.pl was created since the last time the slocate database was
created, locate will fail to find it until it has a chance to discover
it next time slocate runs.

-Andy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4492 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.fedoraproject.org/pipermail/users/attachments/20051108/0e5ba0e7/attachment-0002.bin 


More information about the users mailing list