Extracting the values greater than a threshold in text file?
In awk
, the default action when an expression evaluates to true is to print the current line. Since you need to check the absolute value of the number, ignoring the sign, an easy trick (mentioned by user elmclose in a comment) is to check that the square root of the number times itself (which will return the number as a positive integer) is greater than the threshold. So you could simply do:
$ awk 'sqrt($2*$2)>=.1 || sqrt($3*$3)>=.1 || sqrt($4*$4)>=.1' file
bcmd -0.1012 0.0010 0.0184 100.0 100.0
bcmd 0.2011 0.0024 0.0126 100.0 100.0