title: Vlookup in awk: how to list anything occuring in file2 but not in file1 at the end of output?
body: <p>I have two files, file 1:</p>
  
  <pre><code>1    800     800     0.51
  2    801     801     0.01
  3    802     802     0.01
  4    803     803     0.23
  </code></pre>
  
  <p>and file 2:</p>
  
  <pre><code>1    800     800     0.55
  2    801     801     0.09
  3    802     802     0.88
  4    804     804     0.24
  </code></pre>
  
  <p>I have an awk script that looks in the second file for values that match the first three columns of the first file.</p>
  
  <pre><code>$ awk 'NR==FNR{a[$1,$2,$3];next} {if (($1,$2,$3) in a) {print $4} else {print "not found"}}' f1 f2
  0.55
  0.09
  0.88
  not found
  </code></pre>
  
  <p>Is there a way to make it such that any rows occurring in file 2 that are not in file 1 are still added at the end of the output, after the matches, such as this:</p>
  
  <pre><code>0.55
  0.09
  0.88
  not found
  4    804     804     0.24
  </code></pre>
  
  <p>That way, when I paste the two files back together, they will look something like this:</p>
  
  <pre><code>1 800 800 0.51 0.55
  2 801 801 0.01 0.09
  3 802 802 0.01 0.88
  4 803 803 0.23 not found
  4 804 804 not found 0.04
  </code></pre>
  
  <p>Or is there any other more elegant solution with completely different syntax?</p>