Click to See Complete Forum and Search --> : the FIND command


optech
03-30-2001, 01:34 PM
i've read the MAN pages for the FIND command, but i'm still a bit hazy on it's use...

if i want to search for a file, how do i do this?

i've tried
find / <file>

where / is the directory i want to search... is this correct?

MBMarduk
03-30-2001, 01:51 PM
Heh, join the club! I too find that manpage fscking cryptic.
I usually use "locate" or "whereis" instead.
But "find" has very broad uses...for scripts for example.

If you tell it to find something it won't tell you unless you tell it to PRINT it to stdout (the console).

I *think* it's : "find -n blahblah.file -print" or something like that.

I'll keep an eye on this thread in case someone comes around with the right syntax. :D

Good luck
-Mike

bdg1983
03-30-2001, 02:13 PM
find /dir/to/search -name filename
works good for me. The search is case sensitive that way. If I want a case insensitive search, I'll do
find /dir/to/search -iname filename

It's also possible to use the normal shell wildcards ( * and ? ) in the file name.

bdg1983
03-30-2001, 02:55 PM
I also prefer using locate as it is certainly much easier to use. Of course it usually displays far to much and that is when the 'find' command comes in handy.

This is from the 'Basic Command' NHF here right at Linuxnewbie.

find x -name y -print

find file y, begin the search from within directory x and print the results to the screen

Also for those new to Linux, the 'locate' command uses it's own database to search and display the filenames/directories you request when using locate. Sometimes you may want to locate a certain file after you install software, but locate cannot find your request. The reason being is the locate database has not been updated to reflect the changes in your filesystem. The 'updatedb' command can be run manually from the commandline, but usually it is scheduled to run through cron on a regular basis.

That's my leason for today. Hope it helps someone.