寻找匹配的“”时出现意外的EOF

寻找匹配的“”时出现意外的EOF

抱歉我在论坛上的英语我发现修复了如何禁用橙色 pi 电脑中的低时钟

 #!/bin/bash 

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 

if [ "$(id -u)" != «0» ]; then 
echo «This script must be executed as root. Exiting» >&2 
exit 1 
fi 

Fex2Bin="$(which fex2bin)" 
if [ «X${Fex2Bin}» = «X» ]; then 
apt-get -f -q -y install sunxi-tools 
fi 

Path2ScriptBin="$(df | awk -F" " '/^\/dev\/mmcblk0p1/ {print $6}')" 
if [ ! -f "${Path2ScriptBin}/script.bin" ]; then 
echo «Can not find script.bin. Ensure boot partition is mounted» >&2 
exit 1 
fi 

MyTmpFile="$(mktemp /tmp/${0##*/}.XXXXXX)"
trap «rm \»${MyTmpFile}\"; exit 0" 0 1 2 3 15 

bin2fex <"${Path2ScriptBin}/script.bin" | grep -v "^LV" | grep -v "^max_freq" | grep -v "^min_freq" | grep -v "^extremity_freq" >"${MyTmpFile}" 
if [ $? -ne 0 ]; then 
echo «Could not convert script.bin to fex. Exiting» >&2 
exit 1 
fi 
cp -p "${Path2ScriptBin}/script.bin" "${Path2ScriptBin}/script.bin.bak" 

sed -i '/\[dvfs_table\]/a \ 
extremity_freq = 1296000000\ 
max_freq = 1200000000\ 
min_freq = 480000000\ 
LV_count = 7\ 
LV1_freq = 1296000000\ 
LV1_volt = 1320\ 
LV2_freq = 1200000000\ 
LV2_volt = 1240\ 
LV3_freq = 1104000000\
LV3_volt = 1180\ 
LV4_freq = 1008000000\ 
LV4_volt = 1140\ 
LV5_freq = 960000000\ 
LV5_volt = 1080\ 
LV6_freq = 816000000\ 
LV6_volt = 1020\ 
LV7_freq = 480000000\ 
LV7_volt = 980' "${MyTmpFile}" 

fex2bin "${MyTmpFile}" "${Path2ScriptBin}/script.bin" >/dev/null 
if [ $? -ne 0 ]; then 
mv "${Path2ScriptBin}/script.bin.bak" "${Path2ScriptBin}/script.bin" 
echo «Writing script.bin went wrong. Nothing changed» >&2 
exit 1 
fi 

echo «Successfully repaired broken overvolting/overclocking settings. Reboot necessary for changes to take effect»

我有这个错误

./fix.sh: line 53: unexpected EOF while looking for matching `"'
./fix.sh: line 59: syntax error: unexpected end of file

你能帮我解决一下吗?这不是我的剧本

答案1

欢迎来到 Unix 和 Linux StackExchange!

./fix.sh: line 53: unexpected EOF while looking for matching `"'

此错误消息可能很棘手,因为它指示脚本的第 53 行,这是 shell 注意到双引号出现问题的地方。通常实际的错误是某处缺少双引号在那之前

您帖子中的代码格式已经在尝试帮助您。请注意,在您发布的代码中,首先只有双引号内的内容 (" ) 内的内容显示为红色。但在这行之后,其他一切变成红色,双引号内的东西是黑色或蓝色:

trap «rm \»${MyTmpFile}\"; exit 0" 0 1 2 3 15

颜色方案的更改意味着该行有一个不成对的双引号(不使用反斜杠转义)。它看起来像是从«...»样式引号到标准双引号的不完整转换。

这一行可能应该是:

trap "rm \"${MyTmpFile}\"; exit 0" 0 1 2 3 15

脚本中的所有«...样式引号也应该转换为常规双引号。»

编写脚本时,切勿使用用任何类型的“智能引号”替换常规单引号或双引号的编辑器。这样的替换通常会破坏脚本。如果您的编辑这样做,请了解如何关闭“智能引号”功能。


./fix.sh: line 59: syntax error: unexpected end of file

该消息告诉您第 59 行有问题,但该脚本只有 58 行。所以问题出在脚本的最后。脚本的最后一行有一个不成对的引号,应该修复。

相关内容