title: AWK-merge files based on key
body: <p>I have two files:</p>
  
  <p><strong>1.txt</strong></p>
  
  <pre><code>jeden:AA 
  dwa:BB 
  trzy:CC 
  cztery:DD 
  piec:EE 
  szesc:FF 
  ttttttt:to 
  siedem:GG 
  osiem:HH 
  dziewiec:II 
  dziesiec:JJ
  </code></pre>
  
  <p><strong>2.txt</strong></p>
  
  <pre><code>JJ:jola 
  EE:ela 
  BB:baska 
  FF:flora 
  II:irga 
  AA:adam 
  to:llll 
  DD:darek 
  CC:celina 
  HH:hela 
  GG:gosia
  </code></pre>
  
  <p>I want to merge the two files based on key. Expected result:</p>
  
  <pre><code>jeden: adam 
  dwa: baska 
  trzy: celina 
  cztery: darek 
  piec: ela 
  szesc: flora 
  ttttttt: llll
  siedem: gosia 
  osiem: hela 
  dziewiec: irga 
  dziesiec: jola
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>$ awk -F ":" '{getline a &lt; "2.txt" split(a, b, ":"); if($2==b[1]) print $1":", b[2]}' 1.txt 
  ttttttt: llll 
  </code></pre>
  
  <p>Thank you for your help.</p>