I am using /bin/ksh for this problem.
I have created some arrays with variable names as the array names:
cnt=1
{ while read myline; do
tempmeas="${meas%%;}"
cto="${meas#;}"
tempstream=$stream
# wholemeas holds the name of the array
# each array name will look like MEAS1, MEAS2, MEAS3....
# and the data goes into each array correctly
wholemeas=`eval echo \`echo "MEAS"$cnt\``
eval $wholemeas[1]="\$tempmeas"
eval $wholemeas[2]="\$cto"
eval $wholemeas[3]="\$stream"
((cnt=cnt+1))
done } < $dspbfile
Now, I am trying to get the information back out of the arrays. I can get it out if I specify the name directly:
echo ${MEAS1[1]}
This give me the correct answer I am looking for. Now, when I do this:
cnt=1
wholemeas=`echo "MEAS"$cnt`
I do get wholemeas=MEAS1[1]. Then when I try to get the value from that position in the array:
echo ${$wholemeas[1]}
I get this error:
./PDSBatch.ksh[341]: ${$wholemeas[1]}: bad substitution
I have tried eval, echo, quotes, back quotes and all the other combinations I can think of. Does anyone know how I can get the values from the arrays while using the wholemeas method of specifying the array names? Thanks.
Allyson