[Gllug] Small shell script challenge

Alain Williams addw at phcomp.co.uk
Tue Dec 16 14:08:58 UTC 2003


On Tue, Dec 16, 2003 at 01:56:53PM +0000, Richard Jones wrote:
> Using something like:
> 
> ls -lR dir | awk '{print $5}' | ....
> 
> I can get a list of numbers (actually including some blank
> lines). What's the quickest way to add up those numbers?

Use awk itself:

	ls -lR dir | awk '{tot += $5} END { printf "%d\n", tot }'

-- 
Alain Williams

#include <std_disclaimer.h>

FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
best interests of our children. See http://www.fathers-4-justice.org
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list