[PLUG] Adding numbers

Mark Martin mmartin at u.washington.edu
Wed Jan 28 21:32:01 UTC 2004


On Thursday 29 January 2004 12:19 am, Sean Whitney wrote:
> I'm grepping through some log files for some numbers.
>
> What can I do to total the values and print that out....  I'm sure there
> is a simple solution, it's just escaping me right now...
>
>
> Sean

Brute force:

[mark at caprice mark]$ sum=0; for n in `grep missing messages*|awk '{print 
$7}'`; do let 'sum = sum + n'; done; echo $sum

Must have the last command, i.e. echo $sum, on the same line as the "done" 
statement.

-- 
---------------------------------------------------------------------
Mark A. Martin, Ph.D.
Applied Mathematics -- Software Development -- Systems Administration
Currently available for employment.
See http://www.amath.washington.edu/~mmartin/resume/ for details.
---------------------------------------------------------------------





More information about the PLUG mailing list