division by zero

Hello,

I am searching for a way to calculate for example 10/100 within a shellscript and the result should be 0.1 and not just 0.

Every alternative i tried just results 0

Thank you in advance

2retti

awk 'BEGIN { print 10/100 }'

try this in shell script

div=$(echo "scale=2; 10 / 100" | bc)

echo "$div"

echo "scale=2;10/100" | bc

It works, but the output is ".1" and not "0.1" :wink:

I can`t calculate further with ".1"

In bc you can.

1 Like

Thats right and it works... Thanks!!!