shell脚本之比大小
#!/bin/bash
#author: oldboy
while :
do
read -p '请输入任意两个整数:' num1 num2
if
expr $num1 + $num2 + 1 &>/dev/null
then [ $? -ne 0 ]
else {
echo "请输入正确的数字"
exit 2
}
fi
[ $num1 -gt $num2 ] && echo "$num1 > $num2"
[ $num1 -lt $num2 ] && echo "$num1 < $num2"
[ $num1 -eq $num2 ] && echo "$num1 = $num2"
done
检查脚本
[root@m01 scripts]# sh compare-size.sh
请输入任意两个整数:1 2
1 < 2
请输入任意两个整数:2 2
2 = 2
请输入任意两个整数: 29 22
29 > 22
来源:CSDN
作者:艺妓与酒
链接:https://blog.csdn.net/xiaobaiqifei/article/details/104010306