LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Simple loop (https://www.linuxquestions.org/questions/linux-newbie-8/simple-loop-908150/)

coldjava 10-14-2011 07:17 AM

Simple loop
 
Can anyone tell me what's wrong with this script? It just won't run .. by the way, i'm running it from a mac terminal. thanks

#!/bin/bash

read -p “How many times? “ N
for ((i=0;i<N;i++)); do
echo “Hello World!”
done

macemoneta 10-14-2011 07:23 AM

The editor you used on the Mac helpfully replaced the double-quotes with smart-quotes. You have to turn that feature off, or use a plain text editor.

druuna 10-14-2011 07:25 AM

Hi,
Quote:

Originally Posted by coldjava (Post 4498320)
It just won't run

That doesn't tell us much...

- Do you get error messages?
- Doesn't it loop?
- Doesn't it ask the "How many times?" question?
- .... ?

Details, please!

coldjava 10-14-2011 07:37 AM

-bash: helloworld.sh: line 2: syntax error near unexpected token `('
done'(i=echo ?Hello World!?N: `

How do i turn the feature off? I'm using TextEdit

macemoneta 10-14-2011 07:40 AM

Go to the TextEdit Preferences menu and uncheck the box for “Smart Quotes”.

You'll then need to retype the quotes.

druuna 10-14-2011 07:42 AM

Hi,

I don't know what your default settings are, but maybe this will also help: Plain text editor for Mac OS X

coldjava 10-14-2011 07:47 AM

It's working now, thanks!!

druuna 10-14-2011 08:30 AM

You're welcome :)

BTW: Can you put up the [SOLVED] tag.
first post -> Thread Tools -> Mark this thread as solved


All times are GMT -5. The time now is 07:47 PM.