Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

TheboL.wwwxxxxx, WWWXXXAPC , wwwxxn.xsss, wwwxxxapc, WWWXXX.VCBA, wwwxxx vba, wwwxxxdoco, Wwwxxx.APC, wwwxxx CN2, can't locate feature.pm in @inc (@inc contains

Links

XODOX
Impressum

#1: Locate Vs Find

Posted on 2004-11-22 17:52:44 by ankitjain1580

Which is more efficient? /if both perform the same
work and are not different then why shoudl we have 2 ?

thanks

ankit jain

____________________________________________________________ ____________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Report this message

#2: Re: Locate Vs Find

Posted on 2004-11-23 05:43:30 by Jagadeesh Bhaskar P

On Mon, 2004-11-22 at 22:22, Ankit Jain wrote:
> Which is more efficient? /if both perform the same
> work and are not different then why shoudl we have 2 ?

As far as I know, locate is based on a database storing locations of
file. It doesnot search physically throughout the directory hierarchy.
So it is many a time faster. But you have to update the database
periodically with an "updatedb" command. Otherwise even error locations
may be the result.

Find doesnt depend on any such databases. It searches throughout the
directory hierarchy. This case results are always more reliable, but
mostly slow.

It can be seen by "finding" a file from the "/" and "locating" the same.

I think that trade-off enough a reason!!

--
With regards,

Jagadeesh Bhaskar P
R&D Engineer
HCL Infosystems Ltd
Pondicherry
INDIA

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Report this message

#3: Re: Locate Vs Find

Posted on 2004-11-25 22:00:18 by linux-newbie

If you look at the 'updatedb' script, you'll even find that it uses
the 'find' command to build the static database. Normally the database
is rebuilt only once per/day -- in the wee hours of the morning if
your computer is on then otherwise, it'll run soon after you turn it
on in the morning (in the default configuration). As Jagadeesh says,
locate is much faster -- basically being a "grep" through a large text
database, but it doesn't contain all the same info as 'find' can access
and is only up-to-date from when it was last run...

linda

Jagadeesh Bhaskar P wrote:

>On Mon, 2004-11-22 at 22:22, Ankit Jain wrote:
>
>
>>Which is more efficient? /if both perform the same
>>work and are not different then why shoudl we have 2 ?
>>
>>
>
>As far as I know, locate is based on a database storing locations of
>file. It doesnot search physically throughout the directory hierarchy.
>So it is many a time faster. But you have to update the database
>periodically with an "updatedb" command. Otherwise even error locations
>may be the result.
>
>Find doesnt depend on any such databases. It searches throughout the
>directory hierarchy. This case results are always more reliable, but
>mostly slow.
>
>It can be seen by "finding" a file from the "/" and "locating" the same.
>
>I think that trade-off enough a reason!!
>
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Report this message

#4: Re: Locate Vs Find

Posted on 2004-11-28 15:13:16 by mailing-lists

Sunday, November 28 14:38:06

> On Mon, 2004-11-22 at 22:22, Ankit Jain wrote:
>
> Which is more efficient? /if both perform the same
> work and are not different then why shoudl we have 2 ?

That's not true, they do not preform the same task.
`find' doesn't find files, it's just a side effect of
the program. `Find's' real occupation is to evaluate files.
a.k.a. to preform tests on them. For example:
find / -atime +1 -fstype ext2 -name core -exec rm '{}' \;
find . \( -fstype nfs -prune\) -o \
\( -type d -a -exec chmod 771 '{}' \; \) -o \
\( -name "*.BAK" -a -exec /bin/rm '{}' \; \) -o \
\( -name "*.sh" -a -exec chmod 755 '{}' \; \)
find /home -xdev -size +500k -ls > blabla
find /usr/include -xtype f -exec grep foobar \
/dev/null '{}' \;
Find recurses down a structure and preforms a stat() system call for each
regular file it encounters.. I advise you to read man page or stat(),
lstat(), readdir and the dirent.h header file..

`Locate's' only purpose is to find files. It builds a database of all
files which then later on can be searched..

There are no. examples of c code directory handeling available in the
snippits section at rdrs.net or more `find' examples in
http://www.rdrs.net/docs/src/reminder.txt

Greetzz..

J.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Report this message

#5: Re: Locate Vs Find

Posted on 2004-12-02 06:07:51 by Stephen Samuel

Locate only finds files by looking up the name in a database.
Once a day it regenerates the database.

If you're just looking for a filename, and you don't mind it being
anywhere up to 24 hours old (sometimes more, but rarely), then
ocate is a FAR faster way to do things.


Find, on the other hand can do WAY more tests than just
the filename, and it can do way more things with a file it
finds than just print it. The find command syntax is
actually a primative programming language. and you can
take actions based on the file type file syatem type
mtime, ctime atime file size, owner etc. etc.

Most, recent, versions of find can even tar up certain
matched files.

'Man find` for nore info on what find is capable of.


Ankit Jain wrote:
> Which is more efficient? /if both perform the same
> work and are not different then why shoudl we have 2 ?

--
Stephen Samuel +1(604)876-0426 samuel@bcgreen.com
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bringing it to light.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Report this message