[Gllug] Sum trouble

Tethys tet at accucard.com
Tue Apr 8 09:31:51 UTC 2003


Leigh Mason writes:

>I can't seem to find any text type utility that will sum these values.
>What would be the usual procedure to achieve this?

It's a bit crude, but:

	#!/bin/sh

	tmpfile="/tmp/foo.$$"
	trap "/bin/rm -f \$tmpfile" 0 INT HUP QUIT TERM

	cut f10 -d" " access_log > "$tmpfile"

	count=$(wc -l "$tmpfile" | sed 's/ *\([0-9]*\).*/\1/')

	(
		cat "$tmpfile"
		while [ $count -gt 1 ]
		do
			echo +
			count=$((count - 1))
		done
		echo p
	) | dc

Tet

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list