LinuxQuestions.org
Help answer threads with 0 replies.
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


Closed Thread
  Search this Thread
Old 01-18-2013, 09:54 PM   #1
Longeron
LQ Newbie
 
Registered: Jan 2013
Posts: 5

Rep: Reputation: Disabled
syntax error near unexpected token 'done' (Bash scripting, first time, loops)


Hi,

I just wrote my first script to learn some of the basic syntax and I've run into a problem. I can't tell what i'm doing wrong:

Code:
#!/bin/bash
SOLVED
When I run it I get
Quote:
/hw.sh: line 15 syntax error near unexpected token done
but if I'm following the guide I'm reading done is the correct word.

It must be something in the way I've written it, and not a problem with the loop syntax. Can anyone tell?

EDIT: apparently my guide omitted the fi after elif, so I thought they were unnecessary. Protip: they are necessary.

Last edited by Longeron; 01-18-2013 at 10:08 PM.
 
Old 01-19-2013, 12:02 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You can debug your script by using set -xv (x stands for execution and v for verbose) in your script to check where it produces error, as follow:-
Code:
#!/bin/bash
set -xv
.....
.....
Anyway, if problem persists, once post that part of your script.

Last edited by shivaa; 01-19-2013 at 12:06 AM.
 
1 members found this post helpful.
Old 01-19-2013, 05:10 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Please do not edit original data from a post as you may help others with your question which they now do not know if it was the same scenario.

As for marking SOLVED, please use the Thread Tools option provided.
 
Old 01-19-2013, 06:52 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Moderator note: please don't trash your threads! As grail pointed out, questions and answers posted at LinuxQuestions feed the LQ knowledge base and may serve others to learn something. Whatever the question be! Please, refrain from doing that in the future. Thread closed, since it's useless now (if by chance you want to restore the original content, please contact me or use the REPORT button in the lower-right corner of your post).
 
  


Closed Thread



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
[SOLVED] -bash: syntax error near unexpected token AmirJamez Ubuntu 3 05-01-2012 07:48 AM
-bash: syntax error near unexpected token `(' akshaykb1 Linux - Newbie 3 11-21-2011 06:45 PM
[SOLVED] bash: syntax error near unexpected token `(' rc5gd Programming 6 07-13-2010 08:54 PM
[SOLVED] bash: syntax error near unexpected token `else' lucmove Programming 9 05-10-2010 09:03 PM
bash: syntax error near unexpected token `(' Folklore Linux - Newbie 1 05-02-2010 03:35 AM

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

All times are GMT -5. The time now is 11:28 AM.

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