The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-27-2008
ajgwin ajgwin is offline
Registered User
  
 

Join Date: May 2008
Posts: 18
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0