syntax error near unexpected token `then'问题的解决
#!/bin/bash
#if program test
echo 'a:'
read a
if [ "$a" = "English" ];then
echo "right"
else
echo "wrong"
fi
我是按照视频上的程序稍作修改写的shell脚本程序,结果执行时出现“syntax error near unexpected token `then'”,看半天没看出原因,上网查了半天,终于搞明白了原因:if 与‘['之间没有加空格导致的。另外,在执行时,我也发现 ‘=’两边必须也得加空格,否则也会出错,不是语法出错,而是不管赋给a的值是多少,程序都会得到if 后面的语句为假,从而得出wrong的情况。
syntax error near unexpected token `then'问题的解决的更多相关文章
- syntax error near unexpected token `then'问题的解决
http://blog.csdn.net/gongmin856/article/details/7690917 #!/bin/bash #if program test echo 'a:' read ...
- syntax error near unexpected token 脚本报错误解决
hadoop老师给了一个shell文件,在windows里面瞅了一眼然后在ubuntu环境下运行就报错了.看了一些博客,用vim -b filename查看的时候发现每一行的末尾都多了一个^M.... ...
- 写shell,运行出错:syntax error near unexpected token `$’do\r”
cygwin下面写shell,运行出错:syntax error near unexpected token `$’do\r” 写shell,运行出错:syntax error near unexpe ...
- Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"
同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...
- Linux中syntax error near unexpected token 错误提示解决方法
Linux中syntax error near unexpected token ... 错误提示有一般有两种原因: 1)window和Linux下换行符不一致导致 window下的换行和Linux下 ...
- 使用cygwin出现syntax error near unexpected token'$'do\r
直接从csdn复制粘贴的.sh代码,放到cygwin下运行sh的时候出错syntax error near unexpected token'$'do\r 解决方法: 1.下载notepad++ 2. ...
- 执行shell脚本提示“syntax error near unexpected token for((i=0;i<$length;i++))”
sh脚本例如以下: #!/usr/bin/env bash county="3 4 5 6 7 8 9 10 11 12 16 29 39 44 53 62 72 84 97 115 128 ...
- Linux 中出现的-bash: syntax error near unexpected token `
版权声明:本文为博主原创文章,未经博主允许不得转载. 在Linux 5中导入数据时,出现下面的错误. -bash: syntax error near unexpected token `(' 检查了 ...
- syntax error near unexpected token `do(写的shell脚本出现格式问题)--->1.问题2.展示信息3.解决方案
1问题:Linux和windows下的回车换行符不兼容的问题 [root@node-01 script]# sh start_zk.sh art_zk.sh: line 3: syntax error ...
随机推荐
- (转) WTF is computer vision?
WTF is computer vision? Posted Nov 13, 2016 by Devin Coldewey, Contributor Next Story Someon ...
- MyBatis学习(二)
前言 昨天的博客简单的记录了MyBatis的起源.作用.配置以及一个简单的查询例子.写到一半的时候,觉得已经学会了MyBatis,可是全写完的时候才发现,如果多个参数查询,如何表的名字与类字段名不一样 ...
- python-print
%s,%d就是占位符.还有%r 只是说明这样的对应:%s-->str();%r-->repr(),什么意思呢?就是说%s调用的是str()函数把对象转化为str类型,而%r是调用了repr ...
- MSER算法介绍
MSER代码编译: matlabroot %如果是VS2010则解压VS2010MEX支持文件到MATLAB根目录 unzip('E:\Software\develop Tools\VS2010MEX ...
- 调用C++动态链接库出现错误
解决方式:将托管 System.String 中的内容复制到非托管内存(Marshal.StringToHGlobalAnsi) class HttpsSend { [DllImport(" ...
- java内存的那些事
在Java中,内存的管理分为以下几个部分: Heap:堆区域,存放对象实例,凡是New出来的东西都存放在此. Stack:栈区域,存放基本数据类型.常量.局部变量.对象的引用地址 Data Segme ...
- 关于redis的主从复制
redis主从复制需要注意的一个问题 这两天我朋友在使用redis偶尔会遇见一个问题,就是所有的缓存莫名其妙会不见,找了好久都没找到,他一直以为 有人错误执行了什么命令 他跟我说的时候我估计是主从复制 ...
- 扩展ValidationAttribute 1
MVC中经常会用一些服务端对Model的验证. 服务端验证要继承自ValidationAttribute,并重写IsValid虚方法来自定义自己的验证规则. protected override Va ...
- C# 会可能需要的扩展
1. List 转成DataSet /// <summary> /// 集合数据转成 DataSet /// </summary> /// <typepara ...
- 禁用Windows窗体的关闭按钮
1. protected override void OnFormClosing(FormClosingEventArgs e) { e.Cancel = true; base.OnFormClosi ...