I'm getting a bash: syntax error near unexpected token '('
19,269
bash: syntax error near unexpected token '('
You need to escape the brackets:
mv hiscore\(pre_mame0133u1\).dat /mnt/three/usr/local/share/xmame/hiscore.dat
Note:
For future reference you can use ShellCheck to find bugs in your bash code. Entering the uncorrected script gives the following:
$ 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?
Correcting the first error:
$ 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?
And correcting the second error:
$ 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.
Further Reading
- An A-Z Index of the Bash command line for Linux - An excellent reference for all things Bash command line related.
- syntax-quoting - Escape Characters, delimiters and Quotes
Author by
Kenyon
Updated on September 18, 2022Comments
-
Kenyon over 1 year
I'm working on saving high scores for my Game Elf JAMMA board (412-in-1). I'm currently following this tutorial. I'm trying to run this command
mv hiscore(pre_mame0133u1).dat /mnt/three/usr/local/share/xmame/hiscore.dat
but as you can see in my screenshot, it's returning an error
bash: syntax error near unexpected token '('
-
Kenyon over 6 yearsOk, so I tried that, but now it says 'mv: cannot stat 'hiscore(pre_mame0133u1).dat': No such file or directory` I assume has something to do with it not being able to find the file in my downloads folder? But I don't know for sure.
-
DavidPostill over 6 years@KenyonGeetings Run
ls -l
and see if it's there ... -
Kenyon over 6 yearsI just ran ls -l and this is the output imgur.com/a/3zzWL. So no, it's not there. But how do I go about getting it to show up there? Thanks for all your help so far!
-
DavidPostill over 6 years@KenyonGeetings Did you "Unzip the archive and get the hiscore(pre_mame0133u1).dat file this gets used the rest is not."?
-
meson800 over 6 years@KenyonGeetings, from the upper right of your screenshot, you've unzipped the dat file to Downloads, not to the base of your home directory. The terminal starts in your home directory, so you can either change directory to it (so your commands are relative to Downloads) by doing
cd Downloads
then running the move command above, or adding that part of the path and doingmv Downloads\hiscore\(pre_mame0133u1\).dat /mnt/three/usr/local/share/xmame/hiscore.dat
-
DavidPostill over 6 years@meson800 Well spotted :)
-
Kenyon over 6 years@meson800@DavidPostill thank you both, I got it working!