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)?
|
find DIRECTORY -name FILENAME
If you want to find something within a file I think you can type... grep -R STRING DIRECTORY |
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. |
find for Dummies
http://slackworld.berlios.de/02/classes.html |
Informative post heema. =)
--Abid Kazmi |
All times are GMT -5. The time now is 04:36 PM. |