[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Help Processing a Log File
- Subject: [ale] Help Processing a Log File
- From: fletch at phydeaux.org (Fletch)
- Date: Thu May 13 13:29:29 2004
- In-reply-to: <[email protected]> (Geoffrey's message of "Wed, 12 May 2004 22:10:27 -0400")
- References: <1084406160.9097.93.camel@ibb-250> <[email protected]> <1084410323.9104.99.camel@ibb-250> <[email protected]> <1084411829.9103.102.camel@ibb-250> <[email protected]> <1084412639.9104.104.camel@ibb-250> <[email protected]>
>>>>> "Geoffrey" == Geoffrey <esoteric at 3times25.net> writes:
[...]
Geoffrey> Fletch will likely post a one line solution later
Geoffrey> tonight or tomorrow. :) Glad it worked for you.
Well, I wasn't since yours more or less worked fine . . . :)
Since the username's repeated on the fileend line really all you've
got to watch for are the filestart and fileend lines. This is
presuming that lines for different jobs won't be interspersed.
freebie:~ 611> perl -lane '/^file(\S+)/||next;if($1eq"start"){($p)=$F[2]=~/(\d+)/}else{$p=($F[4]=~/(\d+)/)[0]-$p;$F[-2]=~/-n(\w+)/;print"$p $1"}' foo
9 omard
If lines for different jobs could be interspersed then you'd need to
keep a hash of [ user, start, end ] keyed by job id and then post
process it in an END block.
And just for fun . . .
freebie:~ 637> ruby -lane 'next if !/^file(start|end)/;if($1=="start")then$F[2]=~/(\d+)/;p=$1.to_i;else$F[4]=~/(\d+)/;p=$1.to_i-p;$F[-2]=~/-n(\w+)/;print"#{p} #{$1}";end' foo
9 omard
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U