<div>#!/bin/sh</div><div>a=10</div><div>b=20</div><div>val=`expr $a + $b`</div><div>echo "a + b : $val"</div><div>val=`expr $a - $b`</div><div>echo "a - b : $val"</div><div>val=`expr $a \* $b`</div><div>echo "a * b : $val"</div><div>val=`expr $b / $a`</div><div>echo "b / a : $val"</div><div>val=`expr $b % $a`</div><div>echo "b % a : $val"</div><div>if [ $a == $b ]</div><div>then</div><div> echo "a is equal to b"</div><div>fi</div><div>if [ $a != $b ]</div><div>then</div><div> echo "a is not equal to b"</div><div>fi</div>
复制代码
运行结果:
<div>a + b : 30</div><div>a - b : -10</div><div>a * b : 200</div><div>b / a : 2</div><div>b % a : 0</div><div>a is not equal to b</div>