title: Unix : lookup value from one file to other files based on two joining keys
body: <p>I'm looking for help on joining(at unix level) 2 files(file1 n file2), <br>
  pickup values from file2 as a priority on file1. i.e if value in tmpValue exists on file2 that should be taken instead of file1 srcValue, if no tmpValue on file2 then use srcValue on  file1 tmpValue.<br>
  Note : lookup  has to be done based on 2 key columns : id and dept
  sample</p>
  <pre><code>file1
  ------
  id^dept^name^srcValue
  1^d1^a^s123    
  2^d2^b^s456    
  3^d3^c^        
  
  file2
  --------
  
  id^dept^name
  1^d1^Tva
  3^d3^TVb
  4^d4^Tvm  
  
  Desired output
  ---------------------
  id^dept^name^FinalValue 
  1^d1^a^Tva          
  2^d2^b^s456         
  3^d3^c^TVb      
  </code></pre>
  <p>Below sample code works fine if i consider only 1 column as key  column(id), but I'm not sure how to mention both id and dept as key columns.</p>
  <pre><code>  awk -F&quot;^&quot; 'BEGIN{OFS=&quot;^&quot;} 
                 { 
              if (NR==FNR) { 
                  a[$1]=$3;     
                  next  
              }   
              if ($1 in a){
                  $4=a[$1] 
              }
               print
             }' file2 file1 
  
  
  output of same(above)code
  id^dept^name^name
  1^d1^a^Tva
  2^d2^b^s456
  3^d3^c^TVb
  
  
  </code></pre>