title: awk to match pattern from a file to another file
body: <p>To find a string in a file and print first column of the output, we can use</p>
  <p><code>grep &quot;foo&quot; file.txt | awk '{print $1}'</code> which can be done using <code>awk</code> alone</p>
  <p><code>awk '/foo/ {print $1}' file.txt</code> (<a href="https://stackoverflow.com/a/22866418/1662898">https://stackoverflow.com/a/22866418/1662898</a>).</p>
  <p>Instead of a single string (foo) as a pattern, I want to search for a list of strings in a file. Using <code>grep</code>, it would be</p>
  <pre><code>grep -f file.txt file2.txt | awk '{print $1}' &gt; outFile.txt
  </code></pre>
  <p>Can I do the same using <code>awk</code> alone?</p>
  <pre><code>file.txt
  abcd
  acde
  a2rt
  
  file2.txt
  1 albcd dhakd kdf
  3 abcdbd and
  2a bda2rt tert
  
  outFile.txt
  3
  2a
  </code></pre>
  <p>Thanks!
  Abhishek</p>