#!/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'问题的解决的更多相关文章

  1. syntax error near unexpected token `then'问题的解决

    http://blog.csdn.net/gongmin856/article/details/7690917 #!/bin/bash #if program test echo 'a:' read ...

  2. syntax error near unexpected token 脚本报错误解决

    hadoop老师给了一个shell文件,在windows里面瞅了一眼然后在ubuntu环境下运行就报错了.看了一些博客,用vim -b filename查看的时候发现每一行的末尾都多了一个^M.... ...

  3. 写shell,运行出错:syntax error near unexpected token `$’do\r”

    cygwin下面写shell,运行出错:syntax error near unexpected token `$’do\r” 写shell,运行出错:syntax error near unexpe ...

  4. Linix登录报"/etc/profile: line 11: syntax error near unexpected token `$'{\r''"

    同事反馈他在一测试服务器(CentOS Linux release 7.2.1511)上修改了/etc/profile文件后,使用source命令不能生效,让我帮忙看看,结果使用SecureCRT一登 ...

  5. Linux中syntax error near unexpected token 错误提示解决方法

    Linux中syntax error near unexpected token ... 错误提示有一般有两种原因: 1)window和Linux下换行符不一致导致 window下的换行和Linux下 ...

  6. 使用cygwin出现syntax error near unexpected token'$'do\r

    直接从csdn复制粘贴的.sh代码,放到cygwin下运行sh的时候出错syntax error near unexpected token'$'do\r 解决方法: 1.下载notepad++ 2. ...

  7. 执行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 ...

  8. Linux 中出现的-bash: syntax error near unexpected token `

    版权声明:本文为博主原创文章,未经博主允许不得转载. 在Linux 5中导入数据时,出现下面的错误. -bash: syntax error near unexpected token `(' 检查了 ...

  9. 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 ...

随机推荐

  1. jquery 插件

    1 jquery.slimscroll.min.js:虚拟滚轴 2 jquery.steps.js:步骤(注册下一步) 3 jquery-barcode.js:条形码

  2. C语言标准库函数(网络上copy的)

    C语言标准库函数 标准io函数Standard C I/Oclearerr() clears errorsfclose() close a filefeof() true if at the end- ...

  3. (转)AppiumLibrary基本操作

    *** Settings *** Library AppiumLibrary Library Collections Library String Library Dialogs *** Test C ...

  4. JSPatch 实现原理详解

    原文地址https://github.com/bang590/JSPatch/wiki/JSPatch-%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86%E8%AF%A6%E8 ...

  5. js数组键入值push和 arr[]i]区别

    push 和 arr[i] 遍历 var arr = new Array(); $(":check").each(function(i){if(this.checked==true ...

  6. 好的bootstrap文章

    http://www.cnblogs.com/gamehiboy/p/5176618.html http://www.cnblogs.com/landeanfen/p/5821192.html htt ...

  7. 白电迁移-Auto fdisk

    ============================== fdisk /dev/vdbnp 1 w fdisk -l cd / mkdir /data mkfs.ext4 /dev/vdb1 mo ...

  8. CSS 相邻兄弟选择器

    相邻兄弟选择器(Adjacent sibling selector)可选择紧接在另一元素后的元素,且二者有相同父元素. 选择相邻兄弟 如果需要选择紧接在另一个元素后的元素,而且二者有相同的父元素,可以 ...

  9. NULL指针、零指针、野指针

    1.1.空指针 如果 p 是一个指针变量,则 p = 0; p = 0L; p = '\0'; p = 3 - 3; p = 0 * 17;p=(void*)0; 中的任何一种赋值操作之后, p 都成 ...

  10. SQLServer根据日期查询星期

    --根据日期查询星期SELECT SYSDATETIME();select datepart(weekday,getdate()); SET DATEFIRST 1select '星期'+case w ...