意外的 EOF 和语法错误:

意外的 EOF 和语法错误:

我可以使用终端逐行运行下面的代码,没有问题,但是当我运行脚本文件时,我得到了

line 14: unexpected EOF while looking for matching `"'
line 30: syntax error: unexpected end of file

脚本文件是:

# this script produces edited rinex files from uncompressed rinex files
echo "NECESSARY FILES ARE UNCOMPRESED OBSERVATION (.o) FILES

# example: rnxEditGde.py -d amc20130.18d.Z -rate 30 -out amc2.gz

shopt -s nullglob
shopt -s failglob

i=$(find . -maxdepth 1 -type f -name '*[0-9][0-9]o' -printf 'x' | wc -c)
grep "MARKER NAME" *.[0-9][0-9]o > grep_file
awk -F'[: ]' '{print $1}' grep_file > station_ids

function pl {                
  sed -n "$1p" $2
}

for (( j=1; j <= i; j++ ))
do
ids=$(pl $j station_ids)

rnxEditGde.py -d $ids -rate 30 -out $ids.gz

done

答案1

使用https://www.shellcheck.net/,它将帮助您找到脚本的问题:

$ shellcheck myscript

Line 2:
echo "NECESSARY FILES ARE UNCOMPRESED OBSERVATION (.o) FILES
^-- SC1009: The mentioned syntax error was in this simple command.
     ^-- SC1078: Did you forget to close this double quoted string?

Line 10:
grep "MARKER NAME" *.[0-9][0-9]o > grep_file
     ^-- SC1079: This is actually an end quote, but due to next char it looks suspect.
                 ^-- SC1078: Did you forget to close this double quoted string?

Line 14:
  sed -n "$1p" $2
         ^-- 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 24:

^-- SC1072: Expected end of double quoted string. Fix any mentioned problems and try again.

echo因此,你应该在第 2 行引用该论点

答案2

echo "必要的文件是未压缩的观察(.o)文件

此行应以“(每个开头的双引号都需要结束的双引号)”结尾

echo “必要文件是未压缩的观察(.o)文件”

相关内容