Hi all,
Please could I get some help with a problem I am having with a shell script, the code is below:
====================================================
#!/usr/bin/ksh
set -A array0 green white yellow
set -A array1 dog cat rabbit
set -A array2 zero one two
lj="${array0[1]}"
echo ${lj}
X=3
COUNT=0
while [[ ${COUNT} < ${X} ]]
do
temp="\${array${COUNT}[1]}"
echo ${temp}
(( COUNT=COUNT + 1 ))
done
==================================
This gives the following output:
white
${array0[1]}
${array1[1]}
${array2[1]}
Whereas what I actually want is:
white
white
cat
one
==========================================
I want something that can go through the arrayN and get the value at index[1], if I had say 100 arrays then using the temp and count variables would help but all I seem to get back is the string?
Please point me in the correct direction and help with any pointers if my scripting style is poor. I haven't wrote many scripts and just learn as I go.
Thanks
LGJ
Please could I get some help with a problem I am having with a shell script, the code is below:
====================================================
#!/usr/bin/ksh
set -A array0 green white yellow
set -A array1 dog cat rabbit
set -A array2 zero one two
lj="${array0[1]}"
echo ${lj}
X=3
COUNT=0
while [[ ${COUNT} < ${X} ]]
do
temp="\${array${COUNT}[1]}"
echo ${temp}
(( COUNT=COUNT + 1 ))
done
==================================
This gives the following output:
white
${array0[1]}
${array1[1]}
${array2[1]}
Whereas what I actually want is:
white
white
cat
one
==========================================
I want something that can go through the arrayN and get the value at index[1], if I had say 100 arrays then using the temp and count variables would help but all I seem to get back is the string?
Please point me in the correct direction and help with any pointers if my scripting style is poor. I haven't wrote many scripts and just learn as I go.
Thanks
LGJ