Aug 21, 2024
30 + 10
works directly.expr
expr
command is used to evaluate expressions in Bash.expr 30 + 10
40
Addition:
expr 30 + 10
40
Subtraction:
expr 30 - 10
20
Division:
expr 30 / 10
3
Multiplication:
expr 100 * 4
expr 100 \* 4
400
Example of variable declaration and use in math:
my_num1=100
Adding a number to a variable:
expr $my_num1 + 50
150
Adding two variables together:
my_num2=50
expr $my_num1 + $my_num2
150