I have three arrays. One is Master array and that has list of other array in config file.
for e.g (for simplicity I have only defined array with 2 elements each)
set +A MASTERARRAY SQLUPDATE_ONETIME SQLUPDATE_DAILY END_OF_ARRAY
set +A SQLUPDATE_ONETIME update12 update22 END_OF_ARRAY
set +A SQLUPDATE_DAILY update32 update42 END_OF_ARRAY
I am trying to write a shell script (KSH) to iterate over master array to get the list of array to process (for e.g. SQLUDATE_ONETIME) I need to process one by one. Then go through each element of processing array then do something with it. This is what I have so far.. Any help will be appreciated.
--- Code starts here-----
set +A MASTERARRAY SQLUPDATE_ONETIME SQLUPDATE2_DAILYEND_OF_ARRAY
set +A SQLUPDATE update12 update22 END_OF_ARRAY
set +A SQLUPDATE2 update32 update42 END_OF_ARRAY
#echo "first - ${SQLUPDATE[1]}\n"
CTR=0
while [[ ${MASTERARRAY[CTR]} != "END_OF_ARRAY" ]]; do
echo "Processing ${MASTERARRAY[CTR]} element of an TEMPARRAy\n"
ELEMENT=${MASTERARRAY[CTR]}
echo "Processing ${ELEMENT} element of an MASETERARRAY\n"
FIRSTELEMENT=$(eval echo \$${ELEMENT}[$CTR])
echo "This FIRST ELEMENT ${FIRSTELEMENT}\n"
count=0
while [[ $(eval echo \$${ELEMENT}[count]) != "END_OF_ARRAY" ]] ;do
ELMNT2=$(eval echo \$${ELEMENT}[count])
echo "This is the next element of $ELEMENT - <$ELMNT2>\n"
# do some checking and process the element
(( count = count + 1 ))
done
(( CTR = CTR + 1 ))
done
I am having trouble going thru arrays listed in Masterarray - Please help