#!/bin/bash
echo "Please input a integer:"
read interger1
if [ "$interger1" -lt 15 ]; then
echo "The integer1 which you input is lower than 15"
fi
#!/bin/bash
echo "Please input a integer:"
read integer1
if [ "$integer1" -lt 15 ]
then echo "The integer which you input is lower than 15."
fi
#!/bin/bash
echo "Please input a integer:"
read integer1
if test "$integer1" -lt "15";then
echo "The integer you input is lower than 15"
fi
这里的三种写法,最后执行结果都是一样的。不同的就是then的使用,以及 test关键字和 [ ] 是等同的,都是条件判断的使用。
结果:
~/shell_text $ ./2if_other.sh
Please input a integer:
14
The integer you input is lower than 15