Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-03-2004, 02:01 AM   #1
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:

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

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

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

Rep: Reputation: 15

# first let it know which shell you're using.

for param in $@
echo $param;

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, 02:39 AM   #3
LQ Newbie
Registered: Feb 2004
Posts: 5

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



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
how-to: repeat OR iterate shell OR bash command delay OR interval admarshall Linux - General 5 07-18-2005 11:47 PM
Linux4RegularGuys - EASY FTP setup using vsftpd - READ THIS FOR EASY HELP DropHit Linux - Networking 4 11-25-2004 03:44 PM
Easy Bash Script Question skibud2 Linux - Newbie 1 11-17-2004 12:14 PM
Bash script!! need help!!!!!could be easy! yulitao Programming 3 03-25-2004 07:52 PM
Easy bash script question TheRealDeal Linux - General 11 08-26-2003 10:45 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration