[CentOS] Text Proccessing script - advice?

Tue Dec 21 19:35:13 UTC 2010
m.roth at 5-cent.us <m.roth at 5-cent.us>

John Lundin wrote:
> On Tue, Dec 21, 2010 at 08:30:43PM +0200, Roland RoLaNd wrote:
>
> (chuckle) That's a bit more verbose than necessary. As a one-liner:
>
> awk -F, '($4>"09:00:00"){c[$2 "," $3]++};END{for (i in c){print i ","
> c[i]}}' $filename
>

Well, yes, but he also wanted a count....

      mark

> 01368,2010-12-02,4
> 01368,2010-12-03,3
>
> (You might check if you want >="09:00:00", and include the edge case.)
>
> -F,                   # set separator to comma
>
>                       # (automatic loop over all data lines)
> ($4>"09:00:00"){      # do if fourth field greater than 09:...
> c[$2 "," $3]++        # increment hash element pointed to by
>                       # second and third fields separated by comma
>                       # (that is, hash on id,date)
>
> END{                  # after finishing the data
> for (i in c){         # for each observed hash value in array c
> print i "," c[i]      # print the hash value, comma, count
>
> --
>   lundin at fini.net
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>