title: use fields in one file to find fields in another and print all matches with fields from both
body: <p>I am trying to use fields from one file to find all matches from another file and then print all fo the values from both. I would like to match the first field of file one with the first field of file two. and for all possible combinations of matches print fields from both files. something like:</p>
  <pre><code>file_1.txt:
  1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67369.1 188011 bb_T1PKS
  </code></pre>
  <p>and</p>
  <pre><code>file_2.txt
  1051mF-Z1 PHH67296.1 2611 PF00083.25
  1051mF-Z1 PHH67296.1 2611 PF06609.14
  1051mF-Z1 PHH67296.1 2611 PF07690.17
  1051mF-Z1 PHH67305.1 29486 PF07883.12
  1051mF-Z2 PHH58939.2 33999 PF11110.39
  1051mF-Z3 PHH58936.2 55599 PF41114.2
  </code></pre>
  <p>Desired output:</p>
  <pre><code>1051mF-Z1 PHH67296.1 2611 PF00083.25 1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67296.1 2611 PF06609.14 1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67296.1 2611 PF07690.17 1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67305.1 29486 PF07883.12 1051mF-Z1 PHH67392.1 241796 bb_indole    
  1051mF-Z1 PHH67296.1 2611 PF00083.25 1051mF-Z1 PHH67369.1 188011 bb_T1PKS
  1051mF-Z1 PHH67296.1 2611 PF06609.14 1051mF-Z1 PHH67369.1 188011 bb_T1PKS
  1051mF-Z1 PHH67296.1 2611 PF07690.17 1051mF-Z1 PHH67369.1 188011 bb_T1PKS
  1051mF-Z1 PHH67305.1 29486 PF07883.12 1051mF-Z1 PHH67369.1 188011 bb_T1PKS
  </code></pre>
  <p>However the code I have been using:</p>
  <pre><code>awk 'NR==FNR{a[$1]=$0; next} {print $0,a[$1]}' file_1.txt file_2.txt
  </code></pre>
  <p>Only gives me the match from the first line of the first file and ignores the second?</p>
  <p>Current output:</p>
  <pre><code>1051mF-Z1 PHH67296.1 2611 PF00083.25 1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67296.1 2611 PF06609.14 1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67296.1 2611 PF07690.17 1051mF-Z1 PHH67392.1 241796 bb_indole
  1051mF-Z1 PHH67305.1 29486 PF07883.12 1051mF-Z1 PHH67392.1 241796 bb_indole
  </code></pre>
  <p>Any suggestions would be appreciated! I have been able to do this with a loop -- but it takes forever and I was hoping to do it with an awk one liner if possible.</p>