The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 04-23-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
Quote:
Originally Posted by clem2610 View Post
file1: has all words to be searched.
100007
200999
299997

File2: has all file names to be searched.

C:\search1.txt
C:\search2.txt
C:\search3.txt
C:\search4.txt

Outfile: should have all found lines.

Logic: Read each word in file1 and search each file in the list of File2; if the word found; print the entire line in outfile.

Pls help, thanks in advance.
while read string
do
while read filename
do
if [[ `grep -c "$string" $filename` > 0 ]] then
grep "$string" $filename
fi
done < file2
done < file1


cheers,
Devaraj Takhellambam