Reputation: 2714
A shell script is giving me a trouble. It should display some increasing values each iteration. Dividing "1/9" is the source of the problem, and setting count as "1.0" should do the trick but gives me an error instead: 'Illegal number: 1.0'
count=1
rtime=9
until [ $count -eq $rtime ]
do
echo $((($count/$rtime)*10))
sleep 1
count=$(($count+1))
done
Upvotes: 0
Views: 64
Reputation: 1559
set -o nounset # Treat unset variables as an error
count=1
rtime=9
until [ $count -eq $rtime ]
do
echo $(echo "scale=2; $((count*10))/$rtime" | bc)
sleep 1
count=$((count+1))
done
Upvotes: 1
Reputation: 241928
The shell can only do integer arithmetics. For floats, you can try bc
.
Upvotes: 0