作业帮 > 综合 > 作业

shell脚本的if 命令cannot found?

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/09 03:09:26
shell脚本的if 命令cannot found?
我编写了一个非常简单的脚本
/bin/bash
a=1
b=2
if [ "$a" -ne "$b"]
then echo "$a is not the same as $b"
fi
可是在终端运行结果如下:
[root@localhost Desktop]# ./bash4.sh
./bash4.sh:line 7:if[ 1 -ne 2 ]:command not found
./bash4.sh:line 8:syntax error near unexpected token `then'
./bash4.sh:line 8:`then'
[root@localhost Desktop]#
#!/bin/bash
a=1
b=2
if [ "$a" -ne "$b"]; then
echo "$a is not the same as $b"
fi
我习惯这么写 ,试试看