Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable contains variable

Status
Not open for further replies.

shaoji

Programmer
Mar 22, 2004
10
US
How could I put a variable as part of a variable? I know I can do this:

for i in a b c; do
eval a$i=foo$i
done
echo $aa $ab $ac

It will print out fooa foob fooc. But how could I get it using variable? I cannot use
echo $a$i
or
p=\$a$i
echo $p

any idea?

Thanks.
 
Something like this ?
for i in a b c; do
eval a$i=foo$i
done
for i in a b c; do
eval p=\$a$i
echo "p=$p"
done

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top