title: Compare each row of one file with each row of another file
body: <p>I have two files:</p>
  
  <p>file1</p>
  
  <pre><code>cat file1
  A,1
  B,2
  C,2
  D,3
  </code></pre>
  
  <p>file2</p>
  
  <pre><code>cat file2
  A
  A
  A
  B
  B
  C
  C
  D
  </code></pre>
  
  <p>Desired output</p>
  
  <pre><code>cat output
  A,A,1 
  A,A,1
  A,A,1
  B,B,2
  B,B,2
  C,C,2
  C,C,2
  D,D,3
  </code></pre>
  
  <p>As you can see, each line of <code>file1</code> should be matched with each line of <code>file2</code> and if they match, the line from <code>file1</code> should be added to the matched line in <code>file2</code>. I have tried <code>join</code> but it doesn't work. I guess the search needs to be recursive but I am not sure how to do it when two files are involved.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks</p>