共计 287 个字符,预计需要花费 1 分钟才能阅读完成。
#!/bin/bash
read -p "input number1 and number2:" num1 num2 #- p 后面跟提示信息
a=$num1
b=$num2
[-z "$a"]&&{
echo "is input a"
exit 1
}
[-z "$b"]&&{
echo "is input b"
exit 1
}
expr $a + $b + 1 &>/dev/null #判断是否是整数
[$? -ne 0]&&{
echo "input a b is int"
exit 2
}
echo "$a - $b = $(($a - $b))"
if ["$b" = "0"];then
echo "b is no 0"
else
echo "$a / $b = $(($a / $b))"
fi
正文完
发表至: 未分类
2018-04-19