title: Trying to print lines by specific column value in awk
body: <p>I have a file with 400M records. I am trying to write out individual files if they match sctg2 = n where n = 1 to 43. scgt2 is the 5th column. The sample CSV file <strong>(samplef.csv)</strong> is available here: <a href="http://goo.gl/if85vJ" rel="nofollow">http://goo.gl/if85vJ</a></p>
  
  <pre><code>ofips, dfips, ofaf, dfaf, sctg2, tons, value
  1001,1001,1,1,1,10,20
  1001,1002,1,1,1,20,30
  1001,1003,1,1,1,30,40
  1001,1004,1,1,1,40,50
  1001,1001,1,1,2,110,20
  1001,1002,1,1,2,120,30
  1001,1003,1,1,2,130,40
  1001,1004,1,1,2,140,50
  1001,1001,1,1,3,210,20
  1001,1002,1,1,3,220,30
  1001,1003,1,1,3,230,40
  1001,1004,1,1,3,240,50
  </code></pre>
  
  <p>I used awk (Windows 7) and I have tried the following expressions where it will only select those records where sctg2 = 2(all of which give the output as an empty file):</p>
  
  <pre><code>gawk '$5 == 2 {print $1, $2, $6, $7}' samplef.csv &gt; sampleout.csv
  gawk '$5 ~ /2/ {print $1, $2, $6, $7}' samplef.csv &gt; sampleout.csv
  </code></pre>
  
  <p>The expected output <strong>(sampleout.csv)</strong> is:</p>
  
  <pre><code>ofips, dfips, tons, value
  1001,1001,110,20
  1001,1002,120,30
  1001,1003,130,40
  1001,1004,140,50
  </code></pre>
  
  <p>Any help is appreciated, as I am not sure what I am doing wrong here and am at my wits' end. Does the fact that it is a CSV or the regex pattern numeric have any bearing on this? </p>
  
  <p>TIA,</p>
  
  <p>Krishnan</p>