0

I need some help figuring out where my code is hitching up. The code is below:

servers=( Sanger )   
races=( American African Asian)
jobbs=( NCBI )      
ranges=( 1-2, 2-3, 3-4 )

for server in "${servers[@])"
do

for job in "${jobbs[@]}"
do


for race in "${races[@]}"
do

for range in "${ranges[@]}"
do

cd ${RESULTS}
cd "$server"
cd "$job"
cd "$race"
cd "$range"

for CHR in {1..22}
do

mv -v "$CHR".vcf.gz chr"$CHR".dose.vcf.gz
mv -v "$CHR".vcf.gz.csi chr"$CHR".dose.vcf.gz.csi

done   # chromo

done   # range

done   # race

done   # job

done   # server

My Bash terminal returns the errors:

./rename.sh: line 41: unexpected EOF while looking for matching `"'
./rename.sh: line 52: syntax error: unexpected end of file

ShellCheck output is below:

Line 9:
for server in "${servers[@])"
               ^-- SC1009: The mentioned syntax error was in this parameter expansion.

Line 32:
mv -v "$CHR".vcf.gz chr"$CHR".dose.vcf.gz
                            ^-- SC1078: Did you forget to close this double quoted string?

Line 33:
mv -v "$CHR".vcf.gz.csi chr"$CHR".dose.vcf.gz.csi
      ^-- SC1079: This is actually an end quote, but due to next char it looks suspect.
                                ^-- SC1073: Couldn't parse this double quoted string. Fix to allow more checks.

Line 43:
done   # server
               ^-- SC1072: Expected end of double quoted string. Fix any mentioned problems and try again.

Could any please help and check if I've missed something? Thanks!

3

Line 9 (according to the ShellCheck error):

for server in "${servers[@])"

You have a closing parenthesis rather than a closing brace; it should be

for server in "${servers[@]}"
| improve this answer | |
  • Thanks so much! Quarantine doing my head in. – Jared Apr 9 at 8:29
  • @Jared Also indent your code properly. – ctrl-alt-delor Apr 9 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.