一个简单的shell脚本:
#!/bin/bash
echo "input1:"
read FIRST
echo "input2:"
read SECOND
if ["$FIRST" -gt "$SECOND"] ------修改为 if [ "$FIRST" -gt "$SECOND" ]
then
echo "$FIRST is greater than $SECOND"
fi
执行:
[root@localhost shell]# ./test.sh
input1:
12
input2:
10
./test.sh: line 17: [12: command not found
报错,见上面红色行
====
最后找到原因,原来是少了两个空格闹的
把if ["$FIRST" -gt "$SECOND"] ------修改为 if [ "$FIRST" -gt "$SECOND" ] ,程序正确不再报错了
阅读(1591) | 评论(0) | 转发(0) |