Get floating point division in shell script [closed]

Solution 1:

It is not possible to do floating point arithmetic in bash, but you can do this with awk:

a=20 b=100
awk "BEGIN {print($a/$b)}"

Or a little more elegant (thank you, Cyrus):

awk -v a=20 -v b=100 'BEGIN {print(a/b)}'