Sure! There are several methods of doing so. One is to adjust the scale (number of decimal places that bc keeps). You could change the bc line to:
Code:
total=`echo "scale=2; 3/4" | bc -l`;
which returns
Code:
~/shell/casticmtl> ./math.sh
total is .75
That will solve it. Or, printf will do it, and make it a bit more friendly, as far as display money value goes. Change the echo to something like:
Code:
printf "total is \$%0.2g\n" $total
which outputs
Code:
~/shell/casticmtl> ./math.sh
total is $0.75
Just in case you're not familiar with the format, %g is the format for displaying a double, .2 will cause it to retain only the first two decimal places, and the 0 will cause it to be padded with zero's.
That should do it!!