语法错误:"("意外(预计"完成") [英] Syntax error: "(" unexpected (expecting "done")

查看:193
本文介绍了语法错误:"("意外(预计"完成")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我通过目录使用循环这一个非常简单的shell脚本,调用另一个shell脚本。我写我的本地机器(OSX运行bash 3.2)上,并用它在远程服务器上正在运行bash 4.2。

在服务器上,当我输入这庆典,我得到 /斌/庆典,所以我增加了在顶线。我仍然得到这个错误,指着那开头的行 arrIN = ...

  8:run_all_verification.sh:语法错误:(意外(预期完成)

shell脚本:

 #!的/ usr /斌/庆典
所有实验#base名
BASE_EXP_ID = $ 1;因为我在$ {} BASE_EXP_ID *

        通过#split文件名__
        arrIN =($ {//我__ /});
        EXP_ID = $ {arrIN [0]}
        NUM_FEATURES个= $ {arrIN [1]}
        回声$ {EXP_ID} $ {} NUM_FEATURES        SH run_verification.sh $ {EXP_ID} $ {} NUM_FEATURESDONE


解决方案

您的错误消息是从破折号,可能是因为你跑 SH文件名

要运行具有庆典脚本,使用 bash的文件名(或 ./文件名)。

I have a very simple shell script which I'm using to loop through directories, and call another shell script. I wrote it on my local machine (OSX running bash 3.2), and am using it on a remote server running bash 4.2.

On the server, when I type which bash, I get /bin/bash, so I added the line on top. I still get this error, pointing to the line that begins arrIN=...

8: run_all_verification.sh: Syntax error: "(" unexpected (expecting "done")

The shell script:

#!/usr/bin/bash
#base name for all experiments
BASE_EXP_ID=$1;

for i in ${BASE_EXP_ID}*
do
        #split file name by "__"
        arrIN=(${i//__/ });
        EXP_ID=${arrIN[0]}
        NUM_FEATURES=${arrIN[1]}
        echo "${EXP_ID} ${NUM_FEATURES}"

        sh run_verification.sh ${EXP_ID} ${NUM_FEATURES}

done

解决方案

Your error message is from dash, probably because you ran sh filename.

To run a script with bash, use bash filename (or ./filename).

这篇关于语法错误:"("意外(预计"完成")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆