当前位置: 技术问答>linux和unix
哪位高linux高手帮我改改下面的shell脚本程序,谢谢。
来源: 互联网 发布时间:2016-11-26
本文导语: 错误提示: [root@LXQ heiying]# ./1-2-6 2 2 ./1-2-6: line 4: if[-z2]: command not found ./1-2-6: line 4: [-z2]: command not found ./1-2-6: line 5: syntax error near unexpected token `then' ./1-2-6: line 5: `then' [root@LXQ heiying]# vi 1-2-6 [root@L...
错误提示:
[root@LXQ heiying]# ./1-2-6 2 2
./1-2-6: line 4: if[-z2]: command not found
./1-2-6: line 4: [-z2]: command not found
./1-2-6: line 5: syntax error near unexpected token `then'
./1-2-6: line 5: `then'
[root@LXQ heiying]# vi 1-2-6
[root@LXQ heiying]# ./1-2-6 2 2
./1-2-6: line 4: if[-z 2]: command not found
./1-2-6: line 4: [-z: command not found
./1-2-6: line 5: syntax error near unexpected token `then'
./1-2-6: line 5: `then'
源程序:
1 #!/bin/bash
2 a=$1
3 b=$2
4 if[-z $a]||[-z $b]
5 then
6 echo "please enter 2 no"
7 exit 1
8 fi
9 if[$a -eq $b];then
10 echo "number a=number b"
11 else if[$a -gt $b]
12 then
13 echo "number a>number b"
[root@LXQ heiying]# ./1-2-6 2 2
./1-2-6: line 4: if[-z2]: command not found
./1-2-6: line 4: [-z2]: command not found
./1-2-6: line 5: syntax error near unexpected token `then'
./1-2-6: line 5: `then'
[root@LXQ heiying]# vi 1-2-6
[root@LXQ heiying]# ./1-2-6 2 2
./1-2-6: line 4: if[-z 2]: command not found
./1-2-6: line 4: [-z: command not found
./1-2-6: line 5: syntax error near unexpected token `then'
./1-2-6: line 5: `then'
源程序:
1 #!/bin/bash
2 a=$1
3 b=$2
4 if[-z $a]||[-z $b]
5 then
6 echo "please enter 2 no"
7 exit 1
8 fi
9 if[$a -eq $b];then
10 echo "number a=number b"
11 else if[$a -gt $b]
12 then
13 echo "number a>number b"
|
第四行4 if[-z $a]||[-z $b] 应该写成 if [ -z $a ] || [ -z $b ]
注意格式
注意格式