LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to use "find" (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-use-find-331679/)

LinuxSeeker 06-08-2005 06:00 PM

How to use "find"
 
Hello guys, I have read the manual but I haven't quite understood how it works. Can someone please give me an example such as what to do to find a file named "notes.txt" under the "/" directory by searching all the subfolders (and / as well)?

juanbobo 06-08-2005 06:02 PM

find DIRECTORY -name FILENAME

If you want to find something within a file I think you can type...

grep -R STRING DIRECTORY

chrism01 06-09-2005 02:21 AM

To use your request as an example:

find / -name notes.txt 2>/dev/null

The first param ie '/' represents the dir to start from; find automatically recurses down through all sub-dirs from it's starting point, so don't use '/' unless you really are lost ...
the last bit ie '2>/dev/null' sends stderr (ie error msgs) to null, basically throws them away.
Very handy, particularly if you start from '/' as you'll get a lot of these, even as root user...
You can also change '-name' to '-iname' which means match filename case-insensitive.
If you want to use a wildcard eg *.txt, enclose in single quote marks to get the desired effect eg
find . -name '*.txt' 2>/dev/null

Use
man find
to read up on this cmd.

heema 06-09-2005 06:18 AM

find for Dummies
http://slackworld.berlios.de/02/classes.html

securehack 06-10-2005 09:50 AM

Informative post heema. =)

--Abid Kazmi


All times are GMT -5. The time now is 04:36 PM.