[CentOS] Text Proccessing script - advice?

Tue Dec 21 18:30:43 UTC 2010
Roland RoLaNd <r_o_l_a_n_d at hotmail.com>

First of all i'd like to appologize for those who helped me by giving an advice using "perl" i'm ashamed to say that i have no experience with it.

Mark, thanks for your effort in writing the below though could you help me understand how it goes ? the best way to do thigns, is to learn them for future references.

I'm no expert with AWK, so i need your help with the below if possible:



awk 'BEGIN { FS=",";} \ ## awk -f begin triggers the afterwords commands to be executed in awk, with , as field delimiter
    { if ( $4 > "09:00:00" ) { # condition that matched 09 am
         array[ $2 ][1]++; # incrementing count by one though im a bit at a loss with "array" 
         array[ $2 ][ array[$2][1] + 1] = $3 "::" $4; } # couldn't figure it out
    }
    END {
       for j in array {
          for k in array[j] {
             print j, array[j][k]; # prints out what exactly? 
           }
       }
    }

----------------------------------------
> Date: Tue, 21 Dec 2010 12:58:33 -0500
> From: m.roth at 5-cent.us
> To: centos at centos.org
> Subject: Re: [CentOS] Text Proccessing script - advice?
>
> 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
>  in array" will work.
> 
> mark
>
>
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos