Hi, I'm developing a script which contains a multi dimensional array, however for some reason the array is not iterating.
When executing the script, services are listed as arguments from argument 2. Ex voice data sms.
service=${@:2};
for services in $service
do
data_call_type=CALL_TYPE;
data_term=DATA;
voice_call_type=CALL_TYPE;
voice_term=VOICE-MO;
sms_call_type=CALL_TYPE;
sms_term=SMS-MO;
fi
done
path_dir=$TMPDIR/
for services in $service
do
declare -a arr_cust=("A" "B" "C" "D" "E" "F" "G" "H" "I" "J")
declare -a arr_ids=("124" "94" "61" "85" "95" "105" "106" "107" "134" "158")
for index in ${!array[*]};
do
charged_data=`grep -s $data_call_type=$data_term $path_dir/* | grep -s ACS_CUST_ID=${arr_ids[$index]} | wc -l`
notcharged_data=`grep -s $data_call_type=$data_term $path_dir/* | grep -s ACS_CUST_ID={arr_ids[$index]} | wc -l`
eval charged="\$charged_$services"
eval notcharged="\$notcharged_$services"
echo ${services}_charged $charged > $OUTPUTDIR/$(basename $0 .sh).$services.${arr_cust[$index]}
The issue i'm finding is that the grep is not working properly :
grep -s ACS_CUST_ID=${arr_ids[$index]}
also I am noticing that array is not iterating over index of both arrays. what I am after is that the each index perform all greps for charged_data and notcharged_data and output to file with extension listing the value of the index from array 'arr_cust'.
Can someone provide some help where i'm wrong in the above?
---------- Post updated at 12:06 PM ---------- Previous update was at 12:05 PM ----------
Kindly ignore the fact that for loop is doubled. This is because there are additional if conditions in the script