We have to use arthimetic expansion for doing any arithmetic calculations in shell script.
echo $(( 1 + 1 )) - will add 2 value
echo $(( 2 * 2 )) - multiply 2 value
echo $(( 2 / 2 )) - divide the one value by another
echo $(( 5 % 2 )) - modulo of 5 by 2
Note: shell does not support floating point so all the value will be rounded to the nearest number automatically
expr command is also used for calculating the arithmetic expressions
add=`expr 1 + 1`
mul=`expr 2 \* 6`
Note: in order to suppress * as regular expression \ is used before the *
div=`expr 6 / 2 `
modulo=`expr 7 % 2`