Searching in Linux: locate vs. find
Hi, it's late night, and I'm on disk searching commands with my unixacademy DVD training. It primarily discusses two search tools: locate and find.
I understand the difference between two. What I'm asking is, I don't see "locate" to be much used as "find". I read few books and most of them discuss "find", but not "locate". I also searched on forums, most questions about "find". What I'm asking: is "locate" a general mainstream or some kind of "exotic" command? |
Quote:
Quote:
Thor |
Well I am not so sure about locate, but find has a lot strength due to not only all the things it can do but also the exec options make it extremely powerful.
Also, locate is not generally considered standard fare on all distros. |
locate is useful when the database in which it has indexed all the files are up-to-date.
To update the database, use the command updatedb If the database is updated then locate will work faster than find command. Note: If you are running a "updatedb" after very long time then it will take some time to complete. find on other hand is much more powerful and can be combined to search for very specific needs. |
I usually use "locate" (one reason is that "find" is above me). For me it works very well.
But it is from the same "family" of tools: http://www.gnu.org/software/findutil...mono/find.html So no, it is not exotic, but most people seem to prefer find. |
Hi guys, what I'been asking, is "locate" is generally accepted tool? I mean, I'm learning and IT IS ALL NEW TO ME. From my past Windows trainings I remember that various brands tend to present their own, proprietary solutions and push them for you to use. That is my only concern.
|
locate is one of the fundamental tools, beyond just 'accepted'.
So far as people pushing "brand" software regardless of quality, stop worrying. Shed a tear of relief, even: FOSS exists as a standing rebuke to that whole business model. |
Thanks to everyone!
|
Quote:
|
I've been experimenting a lot with "find" and I've got one question. It appears that find is really heavy on resources, at least on my laptop. I created a huge fake data and directory structure, with many thousands files just for sake of experimentation, and I run "find" against it. I also watch my system utilization with "top" is another terminal and there's clear "spike" in utilization when "find" runs.
My question is, is is always like that? Isn't it possible to index its known paths? |
Quote:
'find' OTOH is a basic Unix cmd from way back when. When updatedb is run, it does essentially the same thing as find, but stores the results. You cannot do that with find, unless you want to write your own version of 'updatedb/locate' :) |
I understand that, but "find" allows for setting conditional searches, by file size, date and many other. I don't see how it may be possible with "locate".
|
Helpful thread, i didn't know the difference between the two commands.
How does whereis command differ from find and locate? Does it use updatedb? i read man page, but still don't get it 100%. Code:
|
Quote:
On the other hand, locate is fast. Find, particularly if you are searching over a whole file system isn't, but it is, or can be, clever. Even if locate doesn't directly do what you want, provided that you only need the file name to do whatever it is, you can often do it by feeding the output of locate through, eg, grep to filter the output more, and still be finished before find has really got going. |
Is there another omnipresent tool for conditional file search, one that offers as many options as "find", but as fast as "locate"? My Unix Academy training DVD teaches these two, or there's always a trade-off speed vs. flexibility?
|
All times are GMT -5. The time now is 09:10 PM. |