Using associative array for comparison

Hello together,

i make something wrong... I want an array that contains information to associate it for further processing.

Here is something from my bash... You will know, what I'm trying to do.
I have to point out in advance, that the variable $SYSOS is changing and not as static as in my example:

myuser@server ~ % declare -A os
myuser@server ~ % os["release-notes-sles-11.3"]=" SuSE Linux SLES11-SP3"
myuser@server ~ % echo $os["release-notes-sles-11.3"]
 SuSE Linux SLES11-SP3
myuser@server ~ % SYSOS="release-notes-sles-11.3"
myuser@server ~ % echo $SYSOS
release-notes-sles-11.3
myuser@server ~ % echo $os[$SYSOS]

myuser@server ~ %

As you can see I want to read the array "dynamically", but it does not work.
It does not even work with echo $os[${SYSOS}]

Can someone help me please?

Thank you very much and best greetings,
Dennis

Any element of an array may be referenced using ${name[subscript]}

The braces are required to avoid conflicts with the shell�s expansion operators.

so try:-

echo ${os["$SYSOS"]}

Thank you very much. It worked :slight_smile:

Have a nice day master Yoda!

Greetings,
Dennis