Hello
I wrote a script that reads the file names in a directory and puts them in to one of two arrays based on part of the filename which is a mailbox ID.
For example:
INSURER1_SEND_ARRAY=(`ls -al | awk '/^-/' | awk '{print $9}' | grep ABCD |cut -f1 -d.`)
INSURER2_SEND_ARRAY=(`ls -al | awk '/^-/' | awk '{print $9}' | grep EFGH |cut -f1 -d.`)
This works fine. Now we have 10 insurers I want to make the script scaleable.
To do this I have a text file that contains the Insurer's name and the Mailbox ID. From this I could create the array name:
for INSURER in `cat INSURE_LIST.TXT | cut -d "," -f1`
do
MAILBOX_ID=`cat $DATA/INSURER_LIST.TXT | grep $INSURER | cut -d "," -f2`
ARRAY_NAME=$INSURER"_SEND_ARRAY"
$ARRAY_NAME"=(`ls -al | awk '/^-/' | awk '{print $9}' | grep $MAILBOX_ID | cut -d. -f1`)
done
Relpacing INSURER1_SEND_ARRAY with $ARRAY_NAME gives me a syntax error unexpected token.
Removing the brackets around the command allows me to run the script but it returns this:
aaaaa_SEND_ARRAY=ABCD_MTAD05_MTAD000971-019: command not found
Does anyone know what I'm doing wrong?
Thanks
Alan
I wrote a script that reads the file names in a directory and puts them in to one of two arrays based on part of the filename which is a mailbox ID.
For example:
INSURER1_SEND_ARRAY=(`ls -al | awk '/^-/' | awk '{print $9}' | grep ABCD |cut -f1 -d.`)
INSURER2_SEND_ARRAY=(`ls -al | awk '/^-/' | awk '{print $9}' | grep EFGH |cut -f1 -d.`)
This works fine. Now we have 10 insurers I want to make the script scaleable.
To do this I have a text file that contains the Insurer's name and the Mailbox ID. From this I could create the array name:
for INSURER in `cat INSURE_LIST.TXT | cut -d "," -f1`
do
MAILBOX_ID=`cat $DATA/INSURER_LIST.TXT | grep $INSURER | cut -d "," -f2`
ARRAY_NAME=$INSURER"_SEND_ARRAY"
$ARRAY_NAME"=(`ls -al | awk '/^-/' | awk '{print $9}' | grep $MAILBOX_ID | cut -d. -f1`)
done
Relpacing INSURER1_SEND_ARRAY with $ARRAY_NAME gives me a syntax error unexpected token.
Removing the brackets around the command allows me to run the script but it returns this:
aaaaa_SEND_ARRAY=ABCD_MTAD05_MTAD000971-019: command not found
Does anyone know what I'm doing wrong?
Thanks
Alan