我收到 bash:意外标记‘(’附近的语法错误

我收到 bash:意外标记‘(’附近的语法错误

我正在努力为我的 Game Elf JAMMA 板(412 合 1)保存高分。我目前正在关注本教程。我正在尝试运行此命令

mv hiscore(pre_mame0133u1).dat /mnt/three/usr/local/share/xmame/hiscore.dat

但正如你所看到的我的截图,它返回一个错误

bash:意外标记‘(’附近的语法错误

答案1

bash: syntax error near unexpected token '('

你需要逃脱括号内为:

mv hiscore\(pre_mame0133u1\).dat /mnt/three/usr/local/share/xmame/hiscore.dat

笔记:

供将来参考,您可以使用壳牌检测查找 Bash 代码中的错误。输入未更正的脚本将得到以下内容:

$ shellcheck myscript

Line 1:
mv hiscore(pre_mame0133u1).dat /mnt/three/usr/local/share/xmame/hiscore.dat
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.
          ^-- SC1036: '(' is invalid here. Did you forget to escape it?
          ^-- SC1088: Parsing stopped here. Invalid use of parentheses?

纠正第一个错误:

$ shellcheck myscript

Line 1:
mv hiscore\(pre_mame0133u1).dat /mnt/three/usr/local/share/xmame/hiscore.dat
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.
                          ^-- SC1089: Parsing stopped here. Is this keyword correctly matched up?

纠正第二个错误:

$ shellcheck myscript

Line 1:
mv hiscore\(pre_mame0133u1\).dat /mnt/three/usr/local/share/xmame/hiscore.dat
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.

进一步阅读

相关内容