Linux

查找匹配的“”時出現意外的 EOF 問題

  • April 9, 2020

我需要一些幫助來確定我的程式碼在哪裡出現問題。程式碼如下:

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

我的 Bash 終端返回錯誤:

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

ShellCheck 輸出如下:

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.

任何人都可以幫忙並檢查我是否遺漏了什麼?謝謝!

第 9 行(根據 ShellCheck 錯誤):

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

你有一個右括號而不是右括號;它應該是

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

引用自:https://unix.stackexchange.com/questions/578897