How to compare two decimal numbers in bash/awk?

You can do it using Bash’s numeric context:

if (( $(echo "$result1 > $result2" | bc -l) )); then

bc will output 0 or 1 and the (( )) will interpret them as false or true respectively.

The same thing using AWK:

if (( $(echo "$result1 $result2" | awk '{print ($1 > $2)}') )); then

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)