bash中意外的'(' [英] Unexpected '(' in bash

查看:56
本文介绍了bash中意外的'('的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本:

#!/bin/sh

# Use the PhiPack software on our two aligned sets of sequences...
mkdir FcFeABC
cd FcFeABC
../bin/PhiPack/Phi -f ../../Data/Real_Sequences_and_Networks/FcFeABC_alignment.fas -o -v -w 10 -g
cd -

mkdir FcL10
cd FcL10
../bin/PhiPack/Phi -f ../../Data/Real_Sequences_and_Networks/FcL10_alignment.fas -o -v -w 10 -g
cd -

# Use the PhiPack software on the simulated Datasets...
cd ../Data/Simulated_Sequences_and_Networks/Constant_Sex/Theta\ =\ 0.066/Theta\ =\ 0.066/Medium/CutSequences/;
rmus=($(ls -d *.fas))
cd -
absfiles=(../Data/Simulated_Sequences_and_Networks/Constant_Sex/Theta\ =\ 0.066/Theta\ =\ 0.066/Medium/CutSequences/*.fas)
if [ ${#rmus[@]} = ${#absfiles[@]} ]
then
    mkdir ${rmus[@]}
    for ((i=0; i<${#absfiles[@]}; i++));
    do
        cd ${rmus[$i]}
    .../bin/PhiPack/Phi -f ${absfiles[$i]} -o -v -w 10 -g
        cd -
    done
else
    echo "Error, Number of files created and files to be read differs"
fi

第16行命中哪个错误

./runPhiTests.sh: 16: ./runPhiTests.sh: Syntax error: "(" unexpected

这是哪一行:

rmus=($(ls -d *.fas))

我不明白为什么'('是意外的-这是将ls结果简单分配给数组的原因.

I don't understand why the '(' is unexpected - it's a simple assignment of the results of ls to an array.

谢谢, 本·W.

推荐答案

您没有使用bash运行它.您正在从Shebang行#!/bin/sh中使用/bin/sh运行.

You aren't running it with bash. You are running with /bin/sh from your shebang line #!/bin/sh.

要么用bash显式运行bash runPhiTests.sh,要么修复您的shebang行#!/bin/bash.

Either run with bash explicitly bash runPhiTests.sh or fix your shebang line #!/bin/bash.

这篇关于bash中意外的'('的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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