Table of contents
Problem background
Usually when using shell scripts to calculate decimal addition, subtraction, multiplication and division in actual work, the calculation results need to be saved in variables.
Idea analysis
Use the bc method, and use backticks to create new variables to execute subsequent calculation commands (the key below esc in the upper left corner of the keyboard)
Solution
a=100
var=`echo $a+0.1 | bc`
var=`echo $a-0.1 | bc`
var=`echo $a*0.1 | bc`
var=`echo $a/0.1 | bc`