The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 03-12-2009
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 246
Quote:
Originally Posted by Rally_Point View Post
I've thought that maybe there's a way to walk through the first file and with each line then walk through each line in the second file (something like a nested loop statement) and then go from there.
Thanks
Hi, have You tried this?

Something like:


Code:
while read name;do grep "$name" file2;done < file1

And You could do something like:


Code:
while read name;do echo $name:;grep "$name" file2;done < file1

Or some other action based on return value of grep?


Code:
while read name;do ;grep -q "$name" file2 && echo $name found in file2;done < file1

And it would help if You could show the source of the file, if this doesn't work. Have You considered sorting the files and using diff?

Best regards
/Lakris