0.0 0.2 0.4 0.6 ... 2.0
It is possible to accomplish this mission in bash, with the help of bc. My own script is listed below:
#!/bin/bash
for i in {0..20..2}
do
#f=$(printf %3.1f `echo "scale=1; $i/10" | bc`) # old version
printf -v f %3.1f `echo "scale=1; $i/10" | bc` # new version
echo $f
done
The bc command was used because bash cannot handle floating calculation directly.
No comments:
Post a Comment