-   Programming (
-   -   Bash: Iterate through $@ (easy++) (

beatnik007 04-03-2004 02:01 AM

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?


verstapp 04-03-2004 02:25 AM


# 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.

beatnik007 04-03-2004 02:39 AM

Thanks Peter, much appreciated.


All times are GMT -5. The time now is 08:07 AM.