Bash shell script to perform the arithmetic operations
kw.sh
#!/bin/bash

echo -n "10+20  = "; expr 10 + 20
echo -n "10-20  = "; expr 10 - 20
echo -n "10\*20 = "; expr 10 \* 20
echo -n "10/20  = "; expr 10 / 20
Output
kodingwindow@kw:~$ bash kw.sh
10+20  = 30
10-20  = -10
10\*20 = 200
10/20  = 0
kodingwindow@kw:~$ 
Bash shell script to perform the arithmetic operations
kw.sh
#!/bin/bash

echo $((10 + 20))
echo $((10 - 20))
echo $((10 * 20))
echo $((10 / 20))
Output
kodingwindow@kw:~$ bash kw.sh
30
-10
200
0
kodingwindow@kw:~$ 
Bash shell script to perform the arithmetic and relational operations
kw.sh
#!/bin/bash

expr '10' '+' '20'
expr '10' '<' '20'
expr '10' '>' '20'
expr '10' '<' '10'
expr '10' '<=' '10'
expr '10' '>=' '20'
Output
kodingwindow@kw:~$ bash kw.sh
30
1
0
0
1
0
kodingwindow@kw:~$ 
Advertisement