![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Looping question | hemangjani | Shell Programming and Scripting | 2 | 02-24-2006 08:47 AM |
| search question | kf199 | UNIX Desktop for Dummies Questions & Answers | 1 | 12-27-2005 02:20 PM |
| Perl question - looping through an array of hashrefs | kregh99 | Shell Programming and Scripting | 2 | 03-19-2004 06:48 AM |
| nested looping question | Sn33R | Shell Programming and Scripting | 7 | 09-26-2003 11:14 AM |
| looping question | hedrict | UNIX for Dummies Questions & Answers | 1 | 03-11-2002 12:19 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
looping search question
This is my requirement--
I have a list file that contains a list of 50 words. eg word1 word2 word3 I want to search/grep for each of those words in a directory/and subdirectories and list the file in which that word exists. Ne ideas for script/command? I know grep -r <pattern> /direaddress will search for existence of a pattern in all files in a directory...but how will i grep for a pattern in a filelist in directory/subdirectories. Last edited by alfredo123; 11-15-2006 at 12:03 PM. |
| Forum Sponsor | ||
|
|
|
|||
|
Thnx
Thanks a heap Jim...I think the below did the job for me and I needed to search the highest directory to see results from subdirectories.
Code:
!#usr/bin/ksh
#Example usage greptest.sh <filelist> <directory to search>
while read line
do
grep -r ${line} $2
done <$1
exit 0
|