FW: Combining variables

From: Darryl Ousterhout (D.Ousterhout@LABSAFETY.COM)
Date: Thu Mar 18 2004 - 10:58:05 EST


PARM1=hello
PARM2=world
PARM3=bye
 
for i in $PARM1 $PARM2 $PARM3; do
 
echo $i
 
done
 
 
Regards,
-Darryl

________________________________

From: IBM AIX Discussion List [mailto:aix-l@Princeton.EDU] On Behalf Of
Raj Atwal
Sent: Thursday, March 18, 2004 9:48 AM
To: aix-l@Princeton.EDU
Subject: Re: Combining variables

Sorry guys...perhaps I didn't explain it well enough. Let me try
again...
 
If I have three parameters in a script thus:
 
PARM1=hello
PARM2=world
PARM3=bye
 
and I now build a for loop to echo the values
 
for i in 1 2 3
do
echo PARM$i (this is where I am stuck)
done
 
When I run the script I would want to see
 
hello
world
bye
 
instead of
 
PARM1
PARM2
PARM3
 
Hope that is clearer. I am stuck figuring out how to expand the PARM#
into the variable's actually value.
 
TIA

JOSEPH KREMBLAS <JKREMBLAS@REDHEARTGIFTS.COM> wrote:

        PARM10=hello
        AZ=10
        
        echo ${PARM10}${AZ}
        
        Note: Notice the braces around the variable name.
        
        -----Original Message-----
        From: IBM AIX Discussion List [mailto:aix-l@Princeton.EDU] On
Behalf Of
        Raj Atwal
        Sent: Thursday, March 18, 2004 8:20 AM
        To: aix-l@Princeton.EDU
        Subject: Combining variables
        
        
        PARM10=hello
        AZ=10
        
        If I have the above in a script and I want to echo the value of
my
        parameter PARM10, how would I do that by combining my AZ
parameter. For
        instance I want to be able to do
        
        echo $PARM$AZ
        
        and have it echo the value of PARM10 to say hello. I can't
figure how to
        quote it to expand $PARM10.
        
        TIA
        Do you Yahoo!?
        Yahoo! Mail - More reliable, more storage, less spam

Do you Yahoo!?
Yahoo! Mail <http://us.rd.yahoo.com/mailtag_us/*http://mail.yahoo.com>
- More reliable, more storage, less spam



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:43 EDT