linux-tutorial/codes/shell/示例脚本/逻辑控制/使用test进行数值比较.sh

17 lines
210 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
var1=10
var2=5
if [ $var1 -gt 5 ]
then
2019-10-10 08:56:31 +08:00
echo "The test value $var1 is greater than 5"
2019-05-10 11:17:57 +08:00
fi
if [ $var1 -eq $var2 ]
then
2019-10-10 08:56:31 +08:00
echo "The values is equal"
2019-05-10 11:17:57 +08:00
else
2019-10-10 08:56:31 +08:00
echo "The values are different"
2019-05-10 11:17:57 +08:00
fi