in reply to merging content based on common columns of 2 files using grep

what is the output you got?, what is the problem you faced?.
UPDATE
from the code you shown above, it won't work as you expected. because for every line(first column) in the file1 you are printing the only the second column match from file2.
grep will give only the matched indexes in this case
use hash instead
iterate through the second file and load the splitted line into a hash like the first column as key and second column as value(provided your second file is not in huge size)
then when you are iterating the first file, just check exists in the hash, if exists append the hash value as the third column during print
hope this helps

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
  • Comment on Re: merging content based on common columns of 2 files using grep

Replies are listed 'Best First'.
Re^2: merging content based on common columns of 2 files using grep
by heidi (Sexton) on May 06, 2009 at 11:10 UTC
    The output was giving only the second column of the first file as results :(
      Copy+Paste is your friend, friend :)