title: Script for comparing two files and outputs matching values
body: <p></p>
  
  <p>I am looking for a script for comparing two tab-delimited text files and outputs matching value.</p>
  
  <p>I used this bash script but it gives only unique values (in other words, it does not work for such purpose)</p>
  
  <pre class="lang-none prettyprint-override"><code>grep -FwF file_1.txt file_2.txt &gt; out.txt
  </code></pre>
  
  <h3>File_1.txt</h3>
  
  <pre class="lang-none prettyprint-override"><code>ref|apple.1| 
  ref|apple.1| 
  ref|apple.1| 
  ref|peach.1| 
  ref|peach.1|
  ref|peach.1|
  ref|fig.1| 
  ref|pear.1| 
  ref|pear.1| 
  ref|apricot.1| 
  ref|plum.1| 
  ref|grape.1|
  ref|grape.1| 
  ref|grape.1| 
  ref|grape.1|
  </code></pre>
  
  <h3>File_2.txt</h3>
  
  <pre class="lang-none prettyprint-override"><code>ref|apple.1|   prepared_for_goats
  ref|peach.1|   prepared_for_tucans
  ref|fig.1| prepared_for_piegons
  ref|pear.1|    prepared for_pigs
  ref|apricot.1| prepared_for_sheep
  ref|plum.1|    prepared_for_gorilla 
  ref|grape.1|   prepared_for_monkeys
  </code></pre>
  
  <h3>Expected_Output</h3>
  
  <pre class="lang-none prettyprint-override"><code>ref|apple.1|   prepared_for_goats
  ref|apple.1|   prepared_for_goats
  ref|apple.1|   prepared_for_goats
  ref|peach.1|   prepared_for_tucans
  ref|peach.1|   prepared_for_tucans
  ref|peach.1|   prepared_for_tucans
  ref|fig.1| prepared_for_piegons     
  ref|pear.1| prepared for_pigs 
  ref|pear.1|    prepared for_pigs
  ref|apricot.1| prepared_for_sheep
  ref|plum.1|    prepared_for_gorilla 
  ref|grape.1|   prepared_for_monkeys
  ref|grape.1|   prepared_for_monkeys
  ref|grape.1|   prepared_for_monkeys
  ref|grape.1|   prepared_for_monkeys
  </code></pre>