Bash and Floating Point operations? Take it easy making use of ‘bc’ smart pipes!
When writing scripts in bash, sometimes we need to work with basic math functions. Like the trigonometric functions, square root, cube root, logarithms. Bash does not support floating point operations. This is where the problem is encountered, and we cannot write a math function of our own. There must be a way to do this, and yes. Bash supports redirections so we can feed the floating point computations and the math functions into some other program’s input who understands it. The program which can be used is the bc, which is an arbitrary precision calculator language. bc can do floating point operations, and also can do basic math functions. With bash and bc we can do the above. Continue reading to know how.
View original post 571 more words