Linux Shell Scripting Tutorial
Introduction Tools required for shell scripting First shell script Interacting with user Operators Special characters in BASH scripting Variables in Linux BASH scripting Arrays Integer operations floating point operations String manipulation in shell scripting Parameter substitution Command Substitution Conditional statements Looping statements Passing parameters exit status of the script Functions Sourcing filesfloating point operations in linux shell scripting
In this topic, let us learn how to perform operations on floating point numbers in Linux. We know that we can use below ways to perform operations on Integer numbers.
a=`expr $b + 1`
a=$((b+2))
let a=b-1
If you try to use floating point numbers in above commands, you will get error saying “non-integer argument” In Linux, we can use “bc” command to perform operations on floating point numbers as shown in below examples.
a=$(echo 2.3 + 3.4 | bc)
Web development and Automation testing
solutions delivered!!