[ale] Help Processing a Log File
Fletch
fletch at phydeaux.org
Thu May 13 13:29:29 EDT 2004
>>>>> "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
More information about the Ale
mailing list