Computing.Net > Forums > Unix > Array

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Array

Reply to Message Icon

Name: Frank
Date: September 9, 2002 at 01:46:00 Pacific
OS: AIX 4.3.3
CPU/Ram: 450-RSIC/4GB
Comment:

Hi,

have a litel problem wiht shell variable handling:
I have a ksh Array variable where the base name of the variable includes a variable itself ${Array$c[*]}
I have some problems in handling of this kind of combination.
e.g:

ArrayFRA[1]="frank"
ArrayBIL[1]="bill"
c=FRA
Now I would like to use this combination:
echo ${Array$c[1]}

but it didn't work.

Doese anybody know a solution ?

Thanks in advance Frank




Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: September 9, 2002 at 08:28:07 Pacific
Reply:

Can these be simple variables instead of array variables, or do you need to use slots other than [1]?

Being array variables makes this a tough problem. I tried all sorts of approaches, finally came up with the following, which pre-constructs the expression string:

ArrayFRA[1]="frank"
ArrayBIL[1]="bill"

c=FRA
Aexpr=\${Array$c[1]}
eval echo $Aexpr

c=BIL
Aexpr=\${Array$c[1]}
eval echo $Aexpr


0

Response Number 2
Name: Frank
Date: September 10, 2002 at 02:39:04 Pacific
Reply:

Hi James,

yes you are right this can be used as work around for this.
But I am not realy satisfiyed with this.
I already use this way in my scripts but
it must exist another soulution.
Anyway thank you very much for your effort.

Frank


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Array

array in Borne Shell www.computing.net/answers/unix/array-in-borne-shell/3957.html

using arrays in a while statement ? www.computing.net/answers/unix/using-arrays-in-a-while-statement-/5003.html

arrayed arrays !! www.computing.net/answers/unix/arrayed-arrays-/4507.html