GitHub - clarity20/shellmath: Yes, Virginia, you can do floating-point arithmetic in Bash!
_shellmath_add 1.009 4.223e-2 _shellmath_getReturnValue sum echo "The sum is $sum" Addition and multiplication are of arbitrary arity; try this on for size: _shellmath_multiply 1 2 3 4 5 6 _shellmath_getReturnValue sixFactorial echo "6 factorial is $sixFactorial" Subtraction and division, OTOH, are exclusively binary operations. The demos shellmath run the demo $ slower_e_demo.sh 15 e = 2.7182818284589936 This script uses a few shellmath API calls to calculate e, the mathematical constant also known as Euler's number. The argument 15 tells the script t...
Source: github.com