[NTLUG:Discuss] sh coding problem
A.L.Lambert
max at xjack.org
Fri Mar 23 15:52:13 CST 2001
On Fri, 23 Mar 2001, Fred James wrote:
> This is Bourne shell scripting.
>
> Given similar environment variables such as
> MOM_CHAIR
> POP_CHAIR
> KID_CHAIR
> I want to build the variable name on the fly and retrieve the value to
> base a decision on in my script.
> Hints?
tmpfile=/tmp/$RANDOM.$$.$RANDOM
echo "NEW_VARIABLE=value" >> $tmpfile
# repeate until bored and/or done
. $tmpfile
rm -f $tmpfile
Not very elegant, but it'll do the trick. However, I'd say based
on your explanation of what you're trying to do, this is not what you're
after. If I'm correct, then maybe a little more detail on your part as to
what you're trying to do, and there may be an easier/better way. Cheers!
--
A.L.Lambert
------------------------------------------------------------------------
The problems that exist in the world today cannot be solved by the level
of thinking that created them...
-Einstein
------------------------------------------------------------------------
More information about the Discuss
mailing list