![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with array=($(find ....) | jul | Shell Programming and Scripting | 1 | 02-27-2008 04:28 PM |
| problem with the blank spaces in array | kamicasse | UNIX for Dummies Questions & Answers | 4 | 12-06-2007 02:40 PM |
| array problem | shary | Shell Programming and Scripting | 6 | 02-10-2007 05:48 AM |
| Point and Array Convert Problem | zhshqzyc | High Level Programming | 0 | 02-25-2006 09:28 PM |
| char array problem | DebianJ | High Level Programming | 4 | 06-25-2005 11:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Array problem
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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|