Two or more arrays in Awk

Hi All,
I have been working on awk and arrays. I have this small script:

cat maillog*|awk -F: '$2=="SMTP-Accept" && $5~/string/ {lastdate=substr($1,1,8); internaluser=$5; v[internaluser]++} END {for (j in v) {print lastdate, v[j], j}'| sort>> mail.list

This gives me the number of mails users are getting. But there is one flaw, :confused: the date is same for all the users. The date field printed out is the very last date it picks and puts it for everyone. Is there a way to save the "last-date" for every user somewhere and print it?
I'm thinking of another array? Any easier and quick solution.
TIA :slight_smile:

Hi Nitin,
I think the reason your dates are all the same is because your print lastdate statement is in the END section of the awk script. This means awk will print what ever the value of lastdate is for the last record. You can confirm this by looking at the date for the last input record and see if that is the same as your script output.
Sorry I don't know how to fix this. I am not sure how you would do a multi-dimensional array in awk, but I am sure it can be done. Your idea of 2 arrays may work as well but you will have to ensure the rows line up correctly so user1 doesn't display user2's lastdate.
Good Luck,
TioTony