linux-tutorial/codes/demos/bash/operator/operatorDemo.sh

31 lines
343 B
Bash
Raw Normal View History

2017-11-17 18:14:22 +08:00
#!/usr/bin/env bash
a=10
b=20
echo "a=$a, b=$b"
val=`expr $a + $b`
echo "a + b : $val"
val=`expr $a - $b`
echo "a - b : $val"
val=`expr $a \* $b`
echo "a * b : $val"
val=`expr $b / $a`
echo "b / a : $val"
val=`expr $b % $a`
echo "b % a : $val"
if [ $a == $b ]
then
echo "a 等于 b"
fi
if [ $a != $b ]
then
echo "a 不等于 b"
fi