关于linux中,在使用script脚本时,老是提示“ [ ” unexpected operator 的问题!
来源:互联网 发布:剑三万花成女捏脸数据 编辑:程序博客网 时间:2024/05/20 16:11
在学习linux script脚本程序的编写时,脚本程序如下所示: 1 #!/bin/bash 2 #Program 3 # This program output "Hello world" 4 #History 5 # 2017.9.20 liuqiqi First release 6 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 7 export PATH 8 if [ "$#" == 0 ] ; then 9 echo "You must input parameters!" 10 exit 0 11 elif [ "$1" == "Hello" ] ; then 12 echo "Hello,how are you?" 13 exit 0 14 else 15 echo "The only parameter you can input is Hello!" 16 exit 0 17 fi一直出现一个问题就是sh09.sh : 8: [ : 0: unexpected operatorsh09.sh: 11: [ : unexpected operator改了好长时间都没改好!后来上网查找之后才发现linux默认的操作环境是dash,而我需要用bash环境才能编译,而我一直使用的是sh sh09.sh(sh09.sh是脚本程序的名字)改成bash sh09.sh就好了!在鸟哥的私房菜中说用bash或者sh执行都可以,实际上我们编写的shell是bash,之所以可以用sh,是因为/bin/sh是个连接文件,连接到/bin/bash,所以执行sh时,其实就是执行bash,但是在ubuntu版本中,/bin/sh默认连接到/bin/dash,所以执行sh,其实是执行dash,所以会出错!
阅读全文
0 0
- 关于linux中,在使用script脚本时,老是提示“ [ ” unexpected operator 的问题!
- Linux shell script遇到unexpected operator错误
- unexpected operator--shell script
- linux shell 学习时遇到的一些问题([: 11: y: unexpected operator)
- shell脚本unexpected operator
- 运行sh提示 unexpected operator
- [Linux] 刚学习shell,碰到问题.执行时总出错:unexpected operator(转载)
- [Linux] 刚学习shell,碰到问题.执行时总出错:unexpected operator(转载)
- [Linux] 刚学习shell,碰到问题.执行时总出错:unexpected operator(转载)
- 在.Net中使用msxsl:script脚本块扩展XSLT的具体实践与应用
- shell脚本中在if语句中比较空串而出现的问题line 5: [: =: unary operator expected
- [: 11: y: unexpected operator问题
- [: 3: y: unexpected operator问题
- 学习shell 时遇到的问题(unexpected operator) 的解决方法
- linux下shell script运行时类似【Syntax error: "(" unexpected】报错问题
- (2010-07-16)关于Oracle中的sys用户认证的问题以及EM中老是提示sys用户密码错误和sys用户密码忘记等问题的解决
- 使用jquery时老是提示$未定义
- 关于UEdit在编辑时老是弹窗提示UEdit已启用
- linux 学习网站
- A星算法详解(个人认为最详细,最通俗易懂的一个版本)
- 101. Symmetric Tree
- #ifndef
- 构建器使用举例-静态工厂和构造器的替代方法
- 关于linux中,在使用script脚本时,老是提示“ [ ” unexpected operator 的问题!
- JSP元素
- tiny4412 设备树之LCD背光驱动(四)(待续)
- c/c++内存管理
- HDU5367-digger
- bzoj3531: [Sdoi2014]旅行
- Python基础(day1)
- 【HDU4089】Activation-概率DP好题
- 《algorithm--算法》课后实验 第一章掷骰子问题