Skip to main content
1 of 6
jlliagre
  • 62.5k
  • 11
  • 124
  • 162

Just use ksh (ksh93 precisely), which supports floating point arithmetics natively:

$ cat test.ksh #!/bin/ksh min=12.45 val=10.35 if (( $val < $min )) ; then min=$val fi echo $min $ ./test.ksh 10.35 

Edit: Sorry, I missed ksh93 was already suggested. Keeping my answer just to make clear the script posted in the opening question can be used with no change outside the shell switch.

jlliagre
  • 62.5k
  • 11
  • 124
  • 162