2

I have the following script:

#!/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

Which hit's an error at line 16:

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

Which is this line:

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

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

Thanks, Ben W.

SJWard
  • 3,629
  • 5
  • 39
  • 54

2 Answers2

4

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

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

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
1

Try to use #!/bin/bash instead of sh.

0xDen
  • 92
  • 3