title: awk, printf, and an equation in a variable
body: <p>I am dynamically generation an equation for awk. Here's an example</p>
  
  <pre><code>//normally eq is dynamically generated
  eq='$1+$2'
  awk -v eq="${eq}" '{printf "%f\n", eq}' myTwoColumns.txt
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>0
  0
  .
  .
  .
  0
  </code></pre>
  
  <p>If it helps, when I add a "$" in front of "eq" in the awk statement:</p>
  
  <pre><code>awk -v eq="${eq}" '{printf "%f\n", $eq}' myTwoColumns.txt
  </code></pre>
  
  <p>the output is the first column. How do I get this to behave like I want it to? Thanks.</p>
  
  <p><strong>Edit: Here's what worked for me</strong></p>
  
  <pre><code>eq='$1+$2'
  awk "{printf \"%f\n\", $eq}" myTwoColumns.txt
  </code></pre>