Results 1 to 3 of 3
I need to substitute the array name by selecting it dynamically.
set -A color red blue green
set -A mobile nokia se moto
m=color
k=mobile
eval echo \${${m}[*]}
I got ...
- 04-20-2009 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
Help with Array name substitution
I need to substitute the array name by selecting it dynamically.
set -A color red blue green
set -A mobile nokia se moto
m=color
k=mobile
eval echo \${${m}[*]}
I got this above logic by searching in this forum.
But i need to get this in the for loop. I'm trying to do something like below
for i in `eval echo \${${m}[*]}` ; do
print $i
done
but this gives an error.
I need to process all elements of an array but the array to select depends on user input.
Can you please help?
Thank you.
- 04-21-2009 #2Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
Still need help!!
Can somebody please help?
If there is no solution to the above problem (pls let me know if there is a very obvious solution), Can you please tell me how i can assign that to a variable and then do the for loop based on it.
- 04-21-2009 #3Just Joined!
- Join Date
- Apr 2009
- Posts
- 3
Got a way to assign it to a variable
eval var=\${${m}[*]}
If somebody knows a better solution, please let me know.


Reply With Quote