Nguyễn Đôn Hào
New member
How do I sum two variables in Bash?
Answer
Bash – Adding Two Numbers
Answer
Bash – Adding Two Numbers
- Using expr command with quotes sum=`expr $num1 + $num2`
- Use expr command inclosed with brackets and start with dollar symbol. sum=$(expr $num1 + $num2)
- This is my preferred way to directly with the shell. sum=$(($num1 + $num2))