Wednesday, February 5, 2014

Using bc in calculations

To use the linux command bc for calculation in shell programs, do the following:
  • Add the line scale=2 to the file ~/.bcrc.
  • Then use var1=`echo "($var2+$var3)/$var4" | bc` to set var1.
Here
  • The scale parameter tells bc to use 2 decimal digits.

No comments:

Post a Comment