title: awk to compare files
body: <p>I'm trying to use awk to find the common lines between two files and save it as a .txt as follows:</p>
  <pre><code>&gt;CL1 1
  lcu_1 lcu_2 lcu_3
  &gt;CL2 1
  lcu_6 lcu_4 lcu_8
  </code></pre>
  <pre><code>&gt;CL1 1
  ler_1 lcu_2 ler_3
  &gt;CL2 1
  lcu_1 lcu_2 lcu_3
  &gt;CL3 1
  lcu_6 lcu_4 lcu_8
  </code></pre>
  <p>Expected output with the two common &quot;CL's&quot;:</p>
  <pre><code>&gt;CL1 1
  lcu_1 lcu_2 lcu_3
  &gt;CL2 1
  lcu_6 lcu_4 lcu_8
  </code></pre>
  <p>The code I'm using:</p>
  <pre><code>awk 'FNR==NR {a[$1]; next} $1 in a' file1.cls file2.cls &gt; out.txt
  </code></pre>
  <p>Actual output:</p>
  <pre><code>CL1 1
  CL2 1
  </code></pre>
  <p>Does anyone know to solve this?</p>