Re: Text Proccessing script - advice?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, Dec 21, 2010 at 02:35:13PM -0500, m.roth@xxxxxxxxx wrote:
> John Lundin wrote:
> > On Tue, Dec 21, 2010 at 08:30:43PM +0200, Roland RoLaNd wrote:
[...]
> Well, yes, but he also wanted a count....

Oh, lord, it's worse than that. I was solving the wrong problem. (And
still am if he really wanted a count of after-nine entries.)

Once again with awk one-liners:

awk -F, '{k=$2 "," $3};(!e[k]||($4<e[k])){e[k]=$4}\
;END{for (i in e){if (e[i]>"09:00:00"){print i "," e[i]}}}' infile \
|tee latedays\
|awk -F, '{c[$1]++};END{for (i in c){print i "," c[i]}}' >latecounts

01368,2010-12-02,09:07:00
01368,2010-12-03,09:02:00

01368,2

You may now wince.

If earliest time seen for user and date is undefined or if this time
is less, then set earliest time to this time. After all processed,
print out the user, date and time if it's later than 09:00:00.

Second awk script just counts lines reported above, by user.
 
(I usually switch to perl or at least a bash script file before it
gets this unreadable. And add some sanity testing.)

-- 
  lundin@xxxxxxxx
"I have a photographic memory. If only I
 could remember where I left the film..."

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux