作业帮 > 综合 > 作业

shell脚本的if 命令cannot found?

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/04/30 00:03:29
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]#
shell脚本的if 命令cannot found?
#!/bin/bash
a=1
b=2
if [ "$a" -ne "$b"]; then
echo "$a is not the same as $b"
fi
我习惯这么写 ,试试看