LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-03-2004, 01:01 AM   #1
beatnik007
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Rep: Reputation: 0
Bash: Iterate through $@ (easy++)


Excuse me for being such a newbie but, well this is the place for it right?

I've been reading the bash manpage, but can't make sense of the definition of "list". As such I don't understand how to iterate through the input parameters. I've tried variations on the following:

Code:
for param in $@ do {
    echo $param;
}
But nothing seems to be syntactically correct.

As an aside, is there a good site for beginners bash?

Thanks
 
Old 04-03-2004, 01:25 AM   #2
verstapp
Member
 
Registered: Feb 2004
Location: canberra australia
Distribution: Suse 9.0
Posts: 44

Rep: Reputation: 15
Try

#!/bin/bash
# first let it know which shell you're using.

for param in $@
do
{
echo $param;
}
done

You need the 'done' to 'close off' the 'do'. Putting the 'do' on a different line from the 'if' means that you don't have to put a ';' after the '$@', there are lots of these little things to learn.
2: type "bash tutorial" into google, there are lots of them.
 
Old 04-03-2004, 01:39 AM   #3
beatnik007
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks Peter, much appreciated.

Cheers
Jem
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how-to: repeat OR iterate shell OR bash command delay OR interval admarshall Linux - General 5 07-18-2005 10:47 PM
Linux4RegularGuys - EASY FTP setup using vsftpd - READ THIS FOR EASY HELP DropHit Linux - Networking 4 11-25-2004 02:44 PM
Easy Bash Script Question skibud2 Linux - Newbie 1 11-17-2004 11:14 AM
Bash script!! need help!!!!!could be easy! yulitao Programming 3 03-25-2004 06:52 PM
Easy bash script question TheRealDeal Linux - General 11 08-26-2003 09:45 PM


All times are GMT -5. The time now is 03:57 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration