FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 12-21-2010, 08:50 PM
John Lundin
 
Default Text Proccessing script - advice?

On Tue, Dec 21, 2010 at 02:35:13PM -0500, m.roth@5-cent.us 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@fini.net
"I have a photographic memory. If only I
could remember where I left the film..."

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-21-2010, 09:00 PM
 
Default Text Proccessing script - advice?

John Lundin wrote:
> On Tue, Dec 21, 2010 at 02:35:13PM -0500, m.roth@5-cent.us 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:

Why? What do you have against more-than-one-line awk scripts?

asks the guy who's written 100 and 200 line awk scripts....

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

Thread Tools




All times are GMT. The time now is 08:42 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org