Is there a function in awk to get the absolute value of a-b which can be negative or positive, I just care for the absolute value...
echo '-12' | nawk '{ print ($1 >= 0) ? $1 : 0 - $1}'
Thanks 80)
Thanks vgersh99, it works for me too!
Hi vgersh99,
I saw this post and I wonder if I have an associative array for calculate an operation; how abs would work in this case.
Assume;
I have
count[$1]=$2-$1;
If I apply the one you suggested in earlier post,
can it be turned to;
count[$1]= ($4-$5)*(0.05);
if(count[$1]>=0){
count[$1]=count[$1];}
else
count[$1]=0-count[$1];
Please advise. Really hope to hear from you soon! Thanks
-Jason
sure, why not!
count[$1]= ($4-$5)*(0.05)
if(count[$1]<0) count[$1]=0-count[$1]