title: How to compare two pairs of columns in two different files and print matches merged horizontally (preference for BASH or AWK)?
body: <p>I'm trying to compare two tab-separated files by matching two different pairs of columns. After a match, I'd like to print the matching lines from both files merged horizontally (that is, side-by-side, akin to BASH paste). The files have 12 columns.</p>
  <p>Looking everywhere I found no similar questions, which honestly makes me worry I might be overthinking the issue.</p>
  <p>Simply put, the goal would be to &quot;match column 1 (in file 1) with column 2 (in file 2)&quot; and &quot;column 2 (in file 1) with column 1 (in file 2)&quot; and only then print the respective matching lines side-by-side.</p>
  <p>An example:</p>
  <p>File1.tsv</p>
  <pre><code>1   A   ExtraInfo
  2   B   ExtraInfo
  3   C   ExtraInfo
  4   D   ExtraInfo
  5   E   ExtraInfo
  </code></pre>
  <p>File2.tsv</p>
  <pre><code>D   4   ExtraInfo
  B   7   ExtraInfo
  E   9   ExtraInfo
  C   3   ExtraInfo
  A   1   ExtraInfo
  </code></pre>
  <p>Desired output:</p>
  <pre><code>1   A   ExtraInfo   A   1   ExtraInfo
  3   C   ExtraInfo   C   3   ExtraInfo
  4   D   ExtraInfo   D   4   ExtraInfo
  </code></pre>
  <p>Although I couldn't find anyone with the same issue, I did find some similar questions that led me to think awk would probably be my best bet. Unfortunately I'm still a complete potato with it, so my attempts are limited to trying to adapt code from similar questions.</p>
  <p>I tried the following, to no avail:</p>
  <pre><code>awk 'NR==FNR{a[$2]=$1 &amp;&amp; a[$1]=$2;next} {print $0,a[$0]}' file1 file2
  </code></pre>
  <p>Nonetheless, if someone can only lend a hand in another language default to Ubuntu I'll still be thankful.</p>