LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   syntax error near unexpected token 'done' (Bash scripting, first time, loops) (https://www.linuxquestions.org/questions/linux-newbie-8/syntax-error-near-unexpected-token-done-bash-scripting-first-time-loops-4175446266/)

Longeron 01-18-2013 09:54 PM

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.

shivaa 01-19-2013 12:02 AM

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.

grail 01-19-2013 05:10 AM

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.

colucix 01-19-2013 06:52 AM

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).


All times are GMT -5. The time now is 06:23 AM.