how to add numbers in linux command line shell 1

how to add numbers in linux command line shell

clear
echo Enter 1st number
read a
echo Enter 2nd number
read b
sum=$(( $a + $b ))
 
echo "Sum is: $sum"

Here is what the above code is Doing:
1. First, we are taking input from the user and storing it in the variable a.
2. Then, we are taking input from the user and storing it in the variable b.
3. Finally, we are adding the two numbers and storing it in the variable sum.
4. Then, we are printing the sum.

Similar Posts