I want to select line of a file where the absolute value of column 9 is less than 500. Column is sometimes positive, sometimes negative.
awk -F\'\\t\' \'{ if
There is a loss of precision using sqrt($9^2). That might be a problem if you want to print the absolute value as well.
Solution: process as text, and simply remove the leading minus sign, if present.
This guarantees that the output matches the input exactly.
Code:
awk '{sub("^-", "", $9); if ($9 < 500) print $9}' inputfile
Summary: to get absolute value using awk, simply remove the leading minus (-) character from a field, if present.