title: awk | Not able to merge 2 files
body: <p>I am new to awk and trying to write code which can merge 2 files..  </p>
  
  <p>File1  </p>
  
  <pre><code>session=123;1,code=01,name=om  
  session=345;3,code=04,name=ra
  </code></pre>
  
  <p>File2  </p>
  
  <pre><code>time=44,minute=22,sec=01,session=123;1,creation=89
  time=34,minute=12,sec=023,session=523;1,creation=80
  </code></pre>
  
  <p>Output should be  </p>
  
  <pre><code>time=44,minute=22,sec=01,session=123;1,creation=89,code=01,name=om
  time=34,minute=12,sec=023,session=523;1,creation=80,,
  </code></pre>
  
  <p>I have written something like:  </p>
  
  <pre><code>BEGIN { FS = OFS = "," }
  FNR == NR {
    a[$2] = substr($0,index($0,$2));
    next
  }
  {
    if($4 in a)print $0","a[$2];
    else print $0",,";
  }
  </code></pre>
  
  <p>But this does not generate the correct output.  </p>
  
  <p>Could you please help where I was mistaken?  </p>