Roland RoLaNd wrote:
I have a log file with the following input: X , ID , Date, Time, Y 01,01368,2010-12-02,09:07:00,Pass 01,01368,2010-12-02,10:54:00,Pass 01,01368,2010-12-02,13:07:04,Pass 01,01368,2010-12-02,18:54:01,Pass 01,01368,2010-12-03,09:02:00,Pass 01,01368,2010-12-03,13:53:00,Pass 01,01368,2010-12-03,16:07:00,Pass
My goal is to get the number of times ID has a TIME that's after 09:00:00 each DATE. That would give me two output. one is the number of days ID has been late, and secondly, the day and time this ID has been late .
awk 'BEGIN { FS=",";} \ { if ( $4 > "09:00:00" ) { array[ $2 ][1]++; array[ $2 ][ array[$2][1] + 1] = $3 "::" $4; } } END { for j in array { for k in array[j] { print j, array[j][k]; } } }
It's been a while since I needed to do this, but I *think* the nested "for <var> in array" will work. <snip> mark