title: Matching and replacing columns
body: <p>I am trying to match the first two columns of two files and replace values of a single column with another column if there is a match.</p>
  <p>If columns 1 &amp; 2 of file1 match 1 &amp; 2 of file2 then I want to replace the 2nd column of file1 with the 3rd column of file 2. I initially was using awk but I was not sure how to match two columns from each file and not just one:</p>
  <p><code>awk -vOFS='\t' 'NR==FNR{a[$1]=$1;a[$2]=$3; next}{$1=a[$1]; $2=a[$2]; print}' file2.txt file1.txt</code></p>
  <p>Thank you in advance for the help!</p>
  <p>file1:</p>
  <pre><code>112 name1 aaaaa
  
  111 name1 aaaaa
  
  122 name2 bbbbb
  
  133 name3 ccccc
  </code></pre>
  <p>file2:</p>
  <pre><code>111 name1 sarah
  
  122 name2 brittany
  
  133 name3 tony
  </code></pre>
  <p>current output:</p>
  <pre><code>    sarah   aaaaa
  
  111 sarah   aaaaa
  
  122 brittany    bbbbb
  
  133 tony    ccccc
  </code></pre>
  <p>expected output:</p>
  <pre><code>112 name1 aaaaa
  
  111 sarah aaaaa
  
  122 brittany bbbbb
  
  133 tony ccccc
  </code></pre>