title: Awk: check if value is not in array
body: <p>I'm trying to read two separate files by awk and parse the second one into output file. </p>
  
  <p>file1 contains numbers:</p>
  
  <pre><code>1
  2
  5
  7
  10
  </code></pre>
  
  <p>file2 contains a header (number of fields &lt;3) and data values in columns (25 columns)</p>
  
  <pre><code>_rlnNrOfSignificantSamples #24 
  _rlnMaxValueProbDistribution #25 
  300.000000 25425.970703 25000.669922     6.050000     2.000000    56.000000     0.277790     79096.000000     0.100000 000001@Particles/Micrographs/006_particles.mrcs   453.000000   604.000000     1.000000     0.859382 Micrographs/006.mrc            1    -3.469177     -3.469177     0.000000     0.000000   -82.345885           23  9475.876495            1     0.988689
  300.000000 25425.970703 25000.669922     6.050000     2.000000    56.000000     0.277790 79096.000000     0.100000 000002@Particles/Micrographs/006_particles.mrcs   431.000000   428.000000     1.000000     0.806442 Micrographs/006.mrc            1    -1.469177    -3.469177     0.000000     0.000000    87.654115           22  9412.959278            1     1.000000
  </code></pre>
  
  <p>I want to read numbers from file1 into array, then:</p>
  
  <ol>
  <li>print header from file2</li>
  <li>print lines from file2, if values in field $22 are NOT in array (in example earlier its values are 23 and 22)</li>
  </ol>
  
  <p>After one day of struggling I came up with the following:
  </p>
  
  <pre><code>#!/bin/bash    
  FieldNum=22
  
  awk -v f=$FieldNum 'FNR==NR{num[$1]; next}
      {
          # print the header of file2
          if(NF &lt; 3) {print &gt; "output"}
          # check lines after header  
          else {if (f in num) {} else {print &gt;&gt; "output"}}
      }' $file1 $file2 
  </code></pre>
  
  <p>But it turns out to print all the lines from file2, so the array checking doesn't work. Could you please spot my mistake?</p>