Re: Another bash scripting question...


Subject: Re: Another bash scripting question...
From: Andrew Dacey (frugal@hfx.eastlink.ca)
Date: Thu Nov 18 1999 - 11:52:28 MST


Well I'm not sure exactly what your getting at. The echo $* at the
begining of your script shows you all of the arguments that were passed
to bash. If you want it to display which variable is which, try
something like this:

#!/bin/bash
count=1
for i in $*
do
        echo \$"$count = $i"
        let count=$count+1
done

Frugal

Jeff Ross wrote:
>
> Hi all!
>
> A bash scripting question, so if this isn't your cup of tea, please feel
> free to pass over this message :-)
>
> This came up in my unix class. Part of the last scripting assignment
> was to display all the positional parameters set by bash when a script
> is called.
>
> I wanted to do it in a loop and this little code piece is what I came up
> with to test the idea.
>
> count=1
> echo $# $*
> while [ $# -ge $count ]
> do echo ${count}
> let count=$count+1
> done
>
> If this little script is called by typing sh looptest one two three,
> the echo${count} displays the value of count (1 2 3) instead of the
> value of $1 $2 or $3, so substitution isn't occurring in the loop.
>
> My instructor and I tried with no success to get this to work last night
> at lab. Any ideas? Or is this something that just can't be done in
> bash?
>
> Awaiting enlightenment :-)
>
> Jeff



This archive was generated by hypermail 2a24 : Fri Dec 03 1999 - 19:07:33 MST