I am trying to replace the $3 column values of the input file if $3 is > 100. I tried:
awk 'BEGIN {FS="\t"} {if($3 > 100) $3=$3/100;print}' test.stat
This outputs the correct changes to the stdout, but I need the change to be written to the input file (test.stat) such that the values of the remaining fields/records remain unchanged. Any suggestion?
Awk isn’t designed to edit things in-place. It’s designed to process data and write it to stdout (or another file). You can do something like this: