LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-03-2011, 02:16 PM   #16
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886

That wouldn't make much sense. If you would store all the options find can test files against in a database you would have to update that database constantly. find is able to find files that were last accessed n minutes ago with the -amin option. In fact, every time a file is accessed, created, deleted or changed, you would have to update the database. That is very resource-consuming, if not even practically impossible.
 
1 members found this post helpful.
Old 05-03-2011, 06:21 PM   #17
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,364

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Exactly; whatever tool you use, it first has to search for the info. With 'find' it does it in real time and is very flexible. With updatedb, this is normally run in cron at eg 4am and only stores filenames/locations.
Other search options are http://linux.die.net/man/1/which & http://linux.die.net/man/1/whereis.
They all have different expectations & limitations.
See the old quote about 'use the right tool for the job'. Best thing is to read up on all 4 options/cmds and decide when you'll use each one.
 
1 members found this post helpful.
Old 05-04-2011, 04:42 AM   #18
kienlarsen
Member
 
Registered: Apr 2011
Posts: 76

Original Poster
Rep: Reputation: 0
Thanks everybody!
 
Old 08-03-2011, 08:50 AM   #19
gnuzilla
LQ Newbie
 
Registered: Apr 2006
Location: Chagrin Falls, OH
Distribution: Ubuntu / Debian
Posts: 17

Rep: Reputation: Disabled
Post Locate vs Find

I work as a Linux Systems Admin, so i use both very often.

When i know the filname or some part of it, and need to know where on the FileSystem something is, I use locate.
Its very fast, low resources is important on those over-shared systems.

When i need to get a list of files to do commands on, often when the parameter is not filname related, i use find.
I use this very often to change permissions.


Code:
#for just the directories from ./,#

 $ find ./ -type d | xargs -I '{}' chmod 755 '{}'

#or for just the files from ./,#

 $ find ./ -type f | xargs -I '{}' chmod 644 '{}'

if i want execute on something with a file extension (such as txt), i would not use find -name unless nessesary for multi-level directories.

Code:
#I prefer the much faster,#

 $ ls *.txt | xargs #COMMAND#

#or if ls somehow unavailable (it has happened, crazy i know)#

 $ echo *.txt | xargs #COMMAND#

so they actually serve very diffrent purposes for me.
i end up using locate much more often, a quick

Code:
#or if i need to remove unrelated listings
 $ locate #FILENAME# | grep -v #FILTEROUT# | less

Hope this helps,
 
Old 08-03-2011, 04:13 PM   #20
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by gnuzilla View Post
if i want execute on something with a file extension (such as txt), i would not use find -name unless nessesary for multi-level directories.

[CODE]#I prefer the much faster,#

$ ls *.txt | xargs #COMMAND#
Just a side note, I would never rely on the output of ls, since its output is thought to be for humans. You may have issues here with filenames that contain spaces (which often happens when you work in heterogeneous networks, Windows and Linux mixed).
 
  


Reply

Tags
find, locate, updatedb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find not searching subdirectories JosephS Linux - Software 6 07-12-2010 10:16 PM
Searching for JDK using find mconstant Linux - Newbie 5 11-20-2008 10:08 AM
'locate' utility can't find db imputerate Linux - Newbie 9 05-26-2008 05:52 AM
Find/locate an exact file stefaandk Linux - General 2 12-27-2005 07:56 AM
cannot find a kernel, please locate one bobotoes Linux - Newbie 2 10-07-2004 06:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration