SUMMARY vi math problem

From: E. Richard Glazier (erglazier@hotmail.com)
Date: Wed May 29 2002 - 14:54:46 EDT


Thanks so much to everyone (and I think everyone resonded!). This was very
educational to me. I need to become more fluent in awk.

Most evryone had an awk solution that went something like this:

>awk '{sum+=+1} END {print sum}' filename

A way to sum each line as you add them, with the total as the additional
last line:

>awk {'print sum += $1'} filename

Here was a pretty slick example of using awk that way"

>ls -l | awk '{sum+=5} END {print sum}'

This totals the file sizes in that directory.

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:48:42 EDT