That is what you told it to do :) $# outputs the number of arguments
input to a script. You should look into the shift built-in function of
(ba)sh. Try something like this:
#!/bin/sh
while [ "$1" ]
do
echo $1
shift
done
Check out:
http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/
Good luck,
Andy.
-----Original Message-----
From: MET [mailto:met@;uberstats.com]
Sent: Wednesday, November 06, 2002 2:07 PM
To: RedHat List
Subject: Bash Script || Loop Through Parameters
I'm trying to loop through all the parameters given to a script. My
script is
executed like so: ./app Matthew Timmy Daniel
for i in $#
do echo Loop iteration - $i
done
This loop just loops once and prints: Loop iteration - 3
Any ideas what I'm doing wrong?
Thanks in Advance
--
Matthew Metnetsky
[EMAIL PROTECTED]
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@;redhat.com?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list