Hi!
I want to quote an array named with a string that includes a pre-defined variable name.
Here's what I mean.
I have a variable that can have two value strings; PR and ET.
So set to PR
I have a text file with values set with the following;
PR_eth_virtual_adapters_lan_id 151 152 151 251 252 251
ET_eth_virtual_adapters_lan_id 351 352 351 451 452 451
If I set ROLE to PR;
ROLE=PR
And then set the array and its values with this;
set -A `grep -E "${ROLE_eth_virtual_adapters_lan_id" ./<text file> | cut -d " " -f 1 ; grep -E
"${ROLE}_eth_virtual_adapters_lan_id" ./<text file> | cut -d " " -f 2-`
that works fine (and should do)
But retrieving the values is harder;
This works fine;
echo ${PR_eth_virtual_adapters_lan_id[*]}
But what I want to do is this;
echo ${ROLE_eth_virtual_adapters_lan_id[*]}
and this doesn't work, or indeed any combination I've tried which embeds the variable name ROLE in the array name.
Any help would be gratefully received!
remshell
I want to quote an array named with a string that includes a pre-defined variable name.
Here's what I mean.
I have a variable that can have two value strings; PR and ET.
So set to PR
I have a text file with values set with the following;
PR_eth_virtual_adapters_lan_id 151 152 151 251 252 251
ET_eth_virtual_adapters_lan_id 351 352 351 451 452 451
If I set ROLE to PR;
ROLE=PR
And then set the array and its values with this;
set -A `grep -E "${ROLE_eth_virtual_adapters_lan_id" ./<text file> | cut -d " " -f 1 ; grep -E
"${ROLE}_eth_virtual_adapters_lan_id" ./<text file> | cut -d " " -f 2-`
that works fine (and should do)
But retrieving the values is harder;
This works fine;
echo ${PR_eth_virtual_adapters_lan_id[*]}
But what I want to do is this;
echo ${ROLE_eth_virtual_adapters_lan_id[*]}
and this doesn't work, or indeed any combination I've tried which embeds the variable name ROLE in the array name.
Any help would be gratefully received!
remshell