title: Compare two files and print matching lines with some lines after match
body: <p>I have two files file1.txt and file2.txt. </p>
  
  <p>file1.txt</p>
  
  <pre><code>DS496218    40654   42783   
  DS496218    40654   42783
  DS496218    40654   42783
  </code></pre>
  
  <p>file2.txt</p>
  
  <pre><code>###
  DS496108    ena gene    99942   102567  .   -       
  DS496128    ena mRNA    99942   102567  .   -       
  DS496118    ena three_prime_UTR 99942   100571  
  ###
  DS496218    ena gene    40654   42783   .   -       
  DS496108    ena mRNA    99942   102567  .   -       
  DS496108    ena three_prime_UTR 99942   100571      
  ###
  DS496128    ena gene    99942   102567  .   -       
  DS496133    ena mRNA    99942   102567  .   -       
  DS496139    ena three_prime_UTR 99942   100571  
  ###
  </code></pre>
  
  <p>I want to match column 1,2 and 3 of file1.txt with column 1,4 and 5 of file2.txt. If it matches print the matching line with the following lines till <code>###</code> but don't print <code>###</code>. I tried it with 'awk' command in </p>
  
  <pre><code>awk -F'\t' 'NR==FNR{c[$1$2$3]++;next};c[$1$4$5] &gt; 0' file1.txt file2.txt &gt; out.txt. 
  </code></pre>