Answers for "bash compare float values"

1

how to compare float values in shell script

# comparing floting points
compare=`echo | awk "{ print ($x < $y)?1 : 0 }"`
echo compare=$compare

if [[ $compare -eq 1 ]]; then
	echo x=$x is less than y=$y
elif [[ $compare -eq 0 ]]; then
	echo y=$y is less than x=$x
fi
Posted by: Guest on June-01-2021
0

if float less than bash

#Just use bc command for operational calculation as follows:
if (( $(echo "$num1 > $num2" |bc -l) )); then
  …
fi
Posted by: Guest on December-17-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language