Bash shell script to perform the arithmetic operations
gd.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
godarda@gd:~$ bash gd.sh 10+20 = 30 10-20 = -10 10\*20 = 200 10/20 = 0 godarda@gd:~$
Bash shell script to perform the arithmetic operations
gd.sh
#!/bin/bash echo $((10 + 20)) echo $((10 - 20)) echo $((10 * 20)) echo $((10 / 20))
Output
godarda@gd:~$ bash gd.sh 30 -10 200 0 godarda@gd:~$
Bash shell script to perform the arithmetic and relational operations
gd.sh
#!/bin/bash expr '10' '+' '20' expr '10' '<' '20' expr '10' '>' '20' expr '10' '<' '10' expr '10' '<=' '10' expr '10' '>=' '20'
Output
godarda@gd:~$ bash gd.sh 30 1 0 0 1 0 godarda@gd:~$
Comments and Reactions