On Mon, Nov 17, 2003 at 09:26:26PM +0100, Serge Maandag wrote:
> Put these lines in a file called "bla" and for the sum of all entries between 
> 10 and 14 try:
> 
> cat bla | grep ' 1[0123]:'|awk '{s += $10}END{print "sum is", s, " average 
> is", s/NR}'

In addition to the "useles use of cat award", this also qualifies
for the "useles use of grep award" :)


To save cpu cycles, file descriptors and what more:

<bla awk '/ 1[0123]:/{s+=$10}END{print "sum is",s," average is ",s/NR}'

This, by the way, selects " 10:" which probably stands for the
timeframe "09:55:00 .. 10:00:00".  After all, a rate is not known
until the time has passed; the entry at 10:00 should thus describe
the past, not the future.  Similarly 14:00:00 is not selected while
it probably should.

HTH
Alex

--
Unsubscribe mailto:[EMAIL PROTECTED]
Help        mailto:[EMAIL PROTECTED]
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

Reply via email to