Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Which find command is best?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
Ben2040
Guru
Guru


Joined: 07 May 2003
Posts: 445
Location: UK

PostPosted: Thu Jun 12, 2003 6:02 am    Post subject: Which find command is best? Reply with quote

Hi
(I hope this is in the right catagory)
I have just used find, which was new to me, and previously I used locate or whereis, and all three have returned different results!! Whats the difference and which is the best?

Ben
Back to top
View user's profile Send private message
dgt84
Guru
Guru


Joined: 27 May 2003
Posts: 355
Location: Germany => USA

PostPosted: Thu Jun 12, 2003 8:22 am    Post subject: Reply with quote

I personally prefer locate, but you need to updatedb very often so that the database is up to speed. Try running updatedb, then run locate, slocate, find, etc... they should all return the same results. I don't know too much about whereis, use it occaisionally to find executables...
_________________
Lila themes | The Porthole Portage Frontend | SVG-Utils
Back to top
View user's profile Send private message
bokkepoot
Tux's lil' helper
Tux's lil' helper


Joined: 14 Mar 2003
Posts: 123
Location: The Hague, The Netherlands

PostPosted: Thu Jun 12, 2003 8:40 am    Post subject: Reply with quote

whereis uses a hardcoded path to search for commands and manpages etc.
(s)locate uses a (prebuilt) database to search for files, which may or may not include the directory your 'wanted' file resides in
find traverses a user given path on a live filesystem to search for the requested files.

So it all depends on what file you are looking for, if its a file that is likely to be in default system path, whereis works probably best, if its eg. a truetype font slocate will be your best shot, if its about files in directories updatedb (used for creating the slocate db) probably won't update, like nfs or user-homes, find will do the trick.. It all depends where you think it might be.
Back to top
View user's profile Send private message
Yarrick
Bodhisattva
Bodhisattva


Joined: 05 Jun 2002
Posts: 304
Location: Malmö, Sweden

PostPosted: Thu Jun 12, 2003 12:29 pm    Post subject: Reply with quote

'which' can also be useful
Back to top
View user's profile Send private message
zephyr1256
Apprentice
Apprentice


Joined: 10 Mar 2003
Posts: 170
Location: Kingsport, TN

PostPosted: Fri Jun 13, 2003 2:40 am    Post subject: Reply with quote

'which' is my favorite command for finding binary executables. It has become most indispensible as of late while I'm working on a basic Linux system on a pair of floppy disks. I need to find out dependencies, etc, for a binary, and I can just do something like:

Code:

ldd `which cat`


And I don't have to worry about 'which' directory the file is in, or for copying the executable to its place in the file system. This could be useful if you were making a script to probe for dependencies of binaries in a filesystem, but you didn't want it to be hard coded to a specific distribution's conventions regarding where they are located.
_________________
The Congress shall have power...To promote the progress of science and useful arts, by securing for limited times to authors and inventors the exclusive right to their respective writings and discoveries; --U.S. Constitution. Article 1, Section 8.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9527
Location: beyond the rim

PostPosted: Fri Jun 13, 2003 4:53 pm    Post subject: Reply with quote

Short answer:
- which is for finding executables
- whereis is for finding manpages, libraries, headerfiles and excutables
- locate is for all files, but it often finds way too much files, a custom find-command is better
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum