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:~$
Comments and Reactions
What Next?
Bash shell script to calculate the area and circumference of a circle
Bash shell script to check a given number is positive or negative
Bash shell script to swap the given numbers and strings
Advertisement