NOTE: If your program depends heavily on Math operation (floating point), better switch to ksh instead of traditional bash.
Bash does not support floating point operations but it's possible to redirects these Math operation to some other program (bc).
The "bc" calculator comes as a part of your Linux distro, so there's no need for you to install anything extra. In addition to performing simple math functions, it can also perform conversions between different number systems, perform a number of scientific math functions, and can even run programs that you write and save in a text file. look the bc man pages for more details.
Below is simple bash script which demonstrate the usage of bc commands in the script
Continue Reading... Bash does not support floating point operations but it's possible to redirects these Math operation to some other program (bc).
The "bc" calculator comes as a part of your Linux distro, so there's no need for you to install anything extra. In addition to performing simple math functions, it can also perform conversions between different number systems, perform a number of scientific math functions, and can even run programs that you write and save in a text file. look the bc man pages for more details.
Below is simple bash script which demonstrate the usage of bc commands in the script
Source: cat floating.sh
#!/bin/bash
echo "----- Addition ------"
x=10.2
y=20.2
z=`echo $x+$y|bc`
echo $z
#!/bin/bash
echo "----- Addition ------"
x=10.2
y=20.2
z=`echo $x+$y|bc`
echo $z
source:http://linuxpoison.blogspot.com/2013/01/13578167757744.html