linux shell脚本syntax error near unexpected token `then'
2016-02-03 10:28
756 查看
1 #!/bin/sh
2 if["$SHELL"="/bin/bash"];then
3 echo "your login shell is the bash(bourne agein shell)"
4 else
5 echo "your login shell is not bash but $SHELL"
6 fi
今天编写了一个简单的shell脚本,执行时报错syntax error near unexpected token `then',
最后才发现:if和[之间一定要有一个空格,添加上之后执行正常。
2 if["$SHELL"="/bin/bash"];then
3 echo "your login shell is the bash(bourne agein shell)"
4 else
5 echo "your login shell is not bash but $SHELL"
6 fi
今天编写了一个简单的shell脚本,执行时报错syntax error near unexpected token `then',
最后才发现:if和[之间一定要有一个空格,添加上之后执行正常。
相关文章推荐
- linux shell 编程 10 脚本中调用脚本
- linux shell 编程 9 for 循环删除文件
- (16)shell文件包含
- (15)shell 输入输出重定向
- (14)shell 函数以及函数参数
- (13)shell break跳出循环
- (12)shell for while until循环
- (11)shell case esac语句
- (10)shell 判断表达式
- shell 编程8 获取 java程序的pid 杀死pid 对应的进程
- (9)shell printf命令:格式化输出
- (8)shell echo命令
- (7)shell数组
- (6)shell字符串
- (5)shell运算符
- 安装XShell 5出现msvcp110.dll错误
- Linux下Java程序的启动shell脚本
- Linux下Java程序的启动shell脚本
- linux shell常用语法
- shell 练习题集合(思路和解答)