"Line 7 : syntax error near unexpected token ')' and Line 7: "option 1-?")"
Hello my name is Tiffney,
I am brand new to Linux and working on an assignment for school. I am writing a script with a loop. The outcome of my script should look like this: [tiffney2018@fedori FinalProject]$ bash MenuProject 1) Option 1 -? 2) Option 2 -? 3) Option 3 - ? 4) Quit Please enter your choice: Instead my end result is: error message: "Line 7 : syntax error near unexpected token ')' "Line 7: "option 1-?")" My script is below: Any help is appreciated. #!/bin/bash PS3='Please enter your choice:' options=('Option 1 - ?" "Option 2 - ?" "Option 3 - ?" "Quit") select opt in "\${options[@]}" do case/$opt in "Option 1 - ?") echo "you chose option 1" ;; "Option 2 - ?") echo "you chose option 2" ;; "Option 3 - ?") echo "you chose option 3" ;; "Quit") break ;; *)echo invalid option;; esac done EOF |
case/$opt in
should not have the /, but a space. The reason line 7 is the error is that the command parsing didn't detect the error until then. Backing up a token at a time shows the error. things would be easier to read using the code /code blocks - that preserves the indentation. |
The script you've posted doesn't generate the error you've posted without a different error being fixed first. When the error you posted is fixed, a different error becomes apparent.
Did you copy/paste your actual script in to your post or type it all out? Check your quotes and currency unit representations. ;) Also as already suggested, put your code blocks, it makes it a lot easier to read. Look for # button in toolbar when composing. |
Thank you jpollard that was it.
I spent 5 days trying to figure out where I went wrong! Greatly appreciated. Forgive me for my ignorance, I am trying to learn so much at once. In both reply's code blocks were suggested, this is not a term I am familiar with, however would like to incorporate your advise when I am writing script. I will search the forum for more information on code blocks. |
Code blocks are identified by "[ code ]" (without the spaces), and "[ /code ]" (again without the spaces), with the programming code inside.
|
code blocks are for the forums, not for your script!
please see my signature. |
All times are GMT -5. The time now is 01:38 AM. |