title: How do I pass a stored value as the column number parameter to edit in awk?
body: <p>I have a .dat file with <code>|</code> separator and I want to change the value of the column which is defined by a number passed as argument and stored in a var. My code is </p>
  
  <pre><code>awk -v var="$value" -F'|' '{ FS = OFS = "|" } $1=="$id" {$"\{$var}"=8}1'   
  myfile.dat &gt; tmp &amp;&amp; mv tmp myfiletemp.dat
  </code></pre>
  
  <p>This changes the whole line to 8, obviously doesn't work. I was wondering what is the right way to write this part</p>
  
  <pre><code>{$"\{$var}"=8}1
  </code></pre>
  
  <p>For example, if I want to change the fourth column to 8 and I have <code>value=4</code>, how do I get <code>{$4=8}</code>?</p>