title: AWK: replace and write a column value in the input file
body: <p>I am trying to replace the $3 column values of the input file if $3 is &gt; 100. I tried:</p>
  <pre class="lang-sh prettyprint-override"><code>awk 'BEGIN {FS=&quot;\t&quot;} {if($3 &gt; 100) $3=$3/100;print}' test.stat
  </code></pre>
  <p>This outputs the correct changes to the stdout but, I need the change to write to the input file (test.stat) such that, the values of the remaining fields/records remain unchanged. Any suggestion?</p>
  <p>Thanks. Another issue has arisen. I have a &quot;counter&quot; variable whose sum needs to be printed in the END block, I tried:</p>
  <pre class="lang-sh prettyprint-override"><code>awk 'BEGIN {FS=&quot;\t&quot;,counter=0} 
  {if($3 &gt; 100) $3=$3/100;print else counter++}
  END{print counter}' test.stat &gt; ...
  </code></pre>
  <p>Now, only the counter value gets written to the file and not the $3 values. How can I separate the two outputs so one modifies the file and the other saved as bash variable using read command. Thanks.</p>