>>>>> "Jessica" == Jessica Mayo <[EMAIL PROTECTED]> writes:

Jessica> On Tue, 18 Mar 2003, John Ferlito wrote:
>> On Tue, Mar 18, 2003 at 06:19:26PM +1100, Jeff Waugh wrote: >
>> Here's some silly shell...
>> >
>> > $ grep bogomips /proc/cpuinfo | awk '{ print "+" $3 }' | tr -d
>> '\n' | cut -c 2- | bc > 6121.06
>> >
>> > Your mission: To work out what it's doing, why you'd be stupid
>> enough to > want to do it, and then how to do it better. It has to
>> be in shell, and it > has to handle decimals! :-)
>> 
>> Too easy. You just need to learn some more awk Mr Waugh :) You
>> don't even need to fork at all.
>> 
>> $ awk '{ if(/bogomips/){ SUM+=$3 } } END {print SUM}' /proc/cpuinfo

Jessica> ... on second thoughts. awk is better. I bow to your
Jessica> awk-lord-ness :)

At least use the pattern matching that's built into AWK:

awk '/bogomips/ { sum += $3 }
END {print sum}' /proc/cpuinfo


PeterC
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to