LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2016, 02:37 PM   #1
tiffney2018
LQ Newbie
 
Registered: May 2016
Posts: 4

Rep: Reputation: Disabled
"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
 
Old 05-05-2016, 02:46 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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.

Last edited by jpollard; 05-05-2016 at 02:49 PM.
 
1 members found this post helpful.
Old 05-05-2016, 03:32 PM   #3
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
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.
 
Old 05-05-2016, 07:50 PM   #4
tiffney2018
LQ Newbie
 
Registered: May 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
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.
 
Old 05-05-2016, 07:58 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Code blocks are identified by "[ code ]" (without the spaces), and "[ /code ]" (again without the spaces), with the programming code inside.
 
Old 05-07-2016, 03:35 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
code blocks are for the forums, not for your script!
please see my signature.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
./project line 1 : Syntax error : unexpected word (expecting ")")... navya Linux - Newbie 29 05-01-2012 09:58 AM
[SOLVED] line 1: syntax error: word unexpected (expecting ")") me011089 Linux - Embedded & Single-board computer 5 08-23-2011 08:34 AM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration