title: Comparing two files in AWK
body: <p>I have two <code>.txt</code> files and I want to check if the contents of one file are present in the other or not. My <code>Book1.txt</code> contents are:</p>
  
  <pre><code>PATX248
  PATX216
  PATX203
  PATX219B
  PATX212
  PATX248
  PATX211
  PATX190
  PATX222
  PATX241
  B8025
  B1003
  B8063
  B8032
  C0999
  C1035
  B1011
  </code></pre>
  
  <p>My <code>InventorySheet2finaloutput.txt</code> is:</p>
  
  <pre><code>B8061P3 366-L4/26/2017 1
  PATX-148 P3 4
   1003P4 M#1N-L1/19/2017
  B1011P5 330-L2/23/2017 1
  B8032P3 336-L3/10/2017 1
  B1011P5 329-L2/14/2017 1
  PATX-60P5 279-L2/8/2017 1
  PATX-70 P3 5
  B1573P6 1R-R8/10/2017 1
  B8025 P4 5
  B8025 P5 1
   1061P3 372-R4/26/2017
   2078 P4M#1RR-R8/25/2017
  C0999 P5 4
  B8078 P4M#1N-R8/25/2017 2
  C-1008 P4 1
  PATX-55 P4 4
  B1003P5 325-R3/3/2017 1
  PATX-45P4 266-L2/14/2017 1
  B8032P4 384-R4/26/2017 1
  C-1035 P3 1
  B8032P3 340-R3/17/2017 1
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>B1003P5 325-R3/3/2017 1
  B8032P3 336-L3/10/2017 1
  B8032P4 384-R4/26/2017 1
  B8032P3 340-R3/17/2017 1
  C0999 P5 4
  C-1035 P3 1
  B1011P5 330-L2/23/2017 1
  B1011P5 329-L2/14/2017 1
  </code></pre>
  
  <p>I have used all the solutions I could search on google, they all are getting executed but no result is being printed. The solutions that I tried are:</p>
  
  <ol>
  <li><code>grep -v -F -x -f Book1.txt InventorySheet2finaloutput.txt</code> (tried grep all forms of flag)</li>
  <li><code>awk 'NR == FNR {Book1[$0]++; next} ($0 in Book1)' Book1.txt InventorySheet2finaloutput.txt</code></li>
  <li><code>awk 'NR==FNR{a[$1];next}$1 in a{print $1}' Book1.txt InventorySheet2finaloutput.txt</code></li>
  <li><code>grep "$(cat Book1.txt)" InventorySheet2finaloutput.txt</code></li>
  </ol>
  
  <p>I want to find if the contents of <code>Book1</code> are present in <code>InventorySheet</code> or not.</p>