LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-14-2011, 08:17 AM   #1
coldjava
LQ Newbie
 
Registered: Oct 2011
Posts: 9

Rep: Reputation: Disabled
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
 
Old 10-14-2011, 08:23 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
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.
 
Old 10-14-2011, 08:25 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,
Quote:
Originally Posted by coldjava View Post
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!
 
Old 10-14-2011, 08:37 AM   #4
coldjava
LQ Newbie
 
Registered: Oct 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
-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
 
Old 10-14-2011, 08:40 AM   #5
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Go to the TextEdit Preferences menu and uncheck the box for “Smart Quotes”.

You'll then need to retype the quotes.
 
Old 10-14-2011, 08:42 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

I don't know what your default settings are, but maybe this will also help: Plain text editor for Mac OS X
 
1 members found this post helpful.
Old 10-14-2011, 08:47 AM   #7
coldjava
LQ Newbie
 
Registered: Oct 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
It's working now, thanks!!
 
Old 10-14-2011, 09:30 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
You're welcome

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Simple While Loop tdlynch88 Linux - Newbie 4 12-02-2010 01:01 AM
simple loop playback olpu Puppy 2 05-02-2010 08:57 PM
A simple for loop in the prompt ? SpLaSh212 Linux - Newbie 2 03-01-2008 12:11 PM
[c shell] simple for loop saiz66 Programming 1 09-28-2004 08:02 PM
Simple for loop lappen Programming 10 09-26-2004 07:36 AM


All times are GMT -5. The time now is 11:54 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration