[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] [Fwd: Internet Cache Usage]



On Wed, 11 Feb 2004, Jonathan Glass wrote:

> Question:  What is the easiest way to get a sum total of all the file
> usage in the report?  I'm going to rerun it sans the -h option so it will
> be in blocks.  Should I just run it through a bash script, doing a cut -f
> 1 and recursively adding the sizes?  Is there a more elegant, command-line
> method?

Generally, awk works better than bash for something like this.

awk '{ foo += $1 } END { print foo }' report.txt

would print out the total (assuming report.txt contains everything in 
blocks, and not humanly readable sizes like it is now)

You could instead do something like

awk '{ foo += $1 } END { print foo/1024 }' report.txt

to convert it back to humanly readable....

later,
chris