Syntax error near unexpected token `done'

May 18, 2014 8.1k views
Hi all, Sorry for a noob question, I'm jus started with Linux today :D My droplet used CentOS 6.5. I have a script name "loop.sh" with this code: #!/bin/bash while : do sl done When I try to run it with command "bash loop.sh" there's error: syntax error near unexpected token `done'. What can I do now? Please help. Thank you so much.
4 Answers
Replace : with ;
See here for more examples
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html
I replaced : with ; then got another error
syntax error near unexpected token `;'
You need a condition for the while loop. See the examples in the link I gave you above.
I copied and created new file with the code in example of the link:

#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done

Nothing changed! There's error:
line 6: syntax error near unexpected token `done'

Why bash programing is too hard???
Have another answer? Share your knowledge.