Hello,
i'm writing a little script that checks a .txt file for a specific ID that came after 9:10 am which outputs it's data to a file LateUsers.txt
once done , it should mention the following:
- Number of late users
- Number of unique late users
- Over all late users percentage
- number of days each user is late
- send an email to each users with his status ( if late to inform him and if not to just state his hours)
what i'm asking for advice with is point 4 and a part of number 5
more specifically can i have an associative array with 3 fields?
for example:
user1 has a Name an ID and an Email
that way i could grep for ID and then grep for tht id to show the name and then use the email of that record to send him an email (i dont have a prob with the mail step)
find below my start up script :
more a*.txt | awk -F, '{if($2 != "X" && !a[$3]) {a[$3]++;if($4 > "09:10:00") print "ID number " $2 " came in on",substr($3,6,5)," at",substr($4,0,5),"after 09:10";}}' > ./LateUsers.txt;
echo "######################################################"
more ./LateUsers.txt;
echo "######################################################"
NumberOfLateUsers=$(more LateUsers.txt | cut -d ' ' -f3 | sort | uniq | wc -l)
echo
echo "number of late users is $NumberOfLateUsers"
echo "######################################################"
echo "which have the following IDs: "
echo
more LateUsers.txt | cut -d ' ' -f3 | sort | uniq
echo "######################################################"
echo
Percentage=`expr $NumberOfLateUsers \\* 100 \/ 27`
echo "Percentage of overall late users is: $Percentage %"
echo "######################################################"
~
~
~