title: How to get a substring in awk
body: <p>This is one line of the input file:</p>
  
  <p>FOO BAR 0.40 0.20 0.40 0.50 0.60 0.80 0.50 0.50 0.50 -43.00 100010101101110101000111010</p>
  
  <p>And an awk command that checks a certain position if it's a "1" or "0" at column 13 
  Something like:</p>
  
  <pre><code> awk -v values="${values}" '{if (substr($13,1,1)==1) printf values,$1,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13}' foo.txt &gt; bar.txt
  </code></pre>
  
  <p>The values variable works, but i just want in the above example to check if the first bit if it is equal to "1".</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok, so I guess I wasn't very clear in my question. The "$13" in the substr method is in fact the bitstring. So this awk wants to pass all the lines in foo.txt that have a "1" at position "1" of the bitstring at column "$13". Hope this clarifies things.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Ok, let me break it down real easy. The code above are examples, so the input line is one of MANY lines. So not all lines have a 1 at position 8. I've double checked to see if a certain position has both occurences, so that in any case I should get some output. Thing is that in all lines it doesn't find any "1"'s on the posistions that I choose, but when I say that it has to find a "0" then it returns me all lines.</p>