哪位高linux高手帮我改改下面的shell脚本程序,谢谢。
时间:2011-05-02
来源:互联网
错误提示:
[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"
作者: zhengyixiaohei 发布时间: 2011-05-02
第四行4 if[-z $a]||[-z $b] 应该写成 if [ -z $a ] || [ -z $b ]
注意格式
注意格式
作者: fengchaokobe 发布时间: 2011-05-02
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28