Absolute Value function in AWK
I was wondering if there was an absolute value function in awk? More specifically, I need it in a string of boolean operators.
Right now I have: awk '{ if ( $1 == 0 && $2 != $1 && [absolute value of $1-$2] <= 6 ) print }' But I don't know what I need to put in the brackets. |
I figured it out, but in case anyone was interested or has a similar problem, the line is:
awk '{ if ( $1 == 0 && $2 != $1 && ( $1-$2 >=0 ? $1=$2 : $2-$1 ) <= 6 ) print }' |
Ummm one could implement an absoluteness function by simply:
function abs(value) { if(value < 0) return value * -1 else return value } didn't test it :) but it should work :P |
That might be simplified to:
Code:
function abs(value) |
All times are GMT -5. The time now is 02:39 PM. |