The find command can search for files with a specific name in a specific directory and all subdirectories. It returns a list of filenames.
The list of filenames can then be passed to egrep which does the searching within the files. So, if you're using the bash shell, you can do the following: egrep "(Welcome|Hello)" $(find -name "*.txt") This searches for either Welcome or Hello in all *.txt files in the current directory or any subdirectory recursively. If you don't need subdirectories you don't need the find command: egrep "(Welcome|Hello)" *.txt On Friday 08 October 2004 11:46, Nicky Formosa wrote: > Hi Jamez > > if i'm not mistaken the find command searches for files only and doesn't > make a torough search within the file itself!? > > am i mistaken or? if so can you give me an example on how i can use the > find command to search for words within a file? > > > Thanks > Nick > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of James Attard > Sent: Friday, October 08, 2004 12:35 PM > To: Malta Linux User Group - general list > Subject: Re: [LINUX.ORG.MT] Search Script > > > Why don't you use 'find' ? > > Jamez. > > -- > http://root-box.info > Registered Linux user #324517 > > > Hi All > > > > I would like to ask you if you can help me with this: > > > > I need a search script that given certain parameters such as: > > > > 1) extension type (multiple) > > and > > 2) search text > > > > i will go through a certain folder and search within the documents > > (extension types chosen) for the given search text/(s). The text, such as > > 'Reports Live', should be searched for both the word 'Reports' and the > > word > > 'Live' seperatly but also together. The result should be a log file with > > the > > names of the documents found! > > > > Is this possible? What i did is the following: > > > > rm search.log > > touch search.log > > > > for i in $1*$2 > > do > > if cat $i | grep -a $3 ; then > > echo $i >> search.log > > fi > > done > > > > Where $1 = the folder searching in > > $2 = One extension only! > > $3 = Search text with no OR > > > > > > This works but its not exactly what i want! Are there any Search tools > > available or? > > > > Tahnks > > Nick > > > > _______________________________________________ > > MLUG-list mailing list > > [email protected] > > http://mailserv.megabyte.net/mailman/listinfo/mlug-list > > _______________________________________________ > MLUG-list mailing list > [email protected] > http://mailserv.megabyte.net/mailman/listinfo/mlug-list > > _______________________________________________ > MLUG-list mailing list > [email protected] > http://mailserv.megabyte.net/mailman/listinfo/mlug-list -- Ramon Casha

