[news.admin] deciding how much news to expire to free disk space

stephen@comp.lancs.ac.uk (Stephen J. Muir) (01/10/87)

Sometimes, when my spool area is in danger of filling up, I decide to do an
expire run with less than the default number of days.  The problem of how many
days worth of news to keep requires a time-consuming examination of the history
file.  So here is a wee awk script to print out the number of news articles
received on each date in the history file:
----------------------------------- Cut Here ----------------------------------
#! /bin/sh
exec awk '
BEGIN	{	FS = "\t"	}
	{	if ($3 == "" || $3 == "cancelled")
			break
		date = $2
		while (substr (date, 1, 1) == " ")
			date = substr (date, 2)
		date = substr (date, 1, 8)
		if (count [date] == 0)
			sort [++number] = date
		++count [date]
	}
END	{	for (i = 1; i <= number; ++i)
		{	date = sort [i]
			printf "%s %s\n", date, count [date]
		}
	}
' < /usr/lib/news/history
----------------------------------- Cut Here ----------------------------------
-- 
EMAIL:	stephen@comp.lancs.ac.uk	| Post: University of Lancaster,
UUCP:	...!mcvax!ukc!dcl-cs!stephen	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4120		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR