From: utzoo!decvax!ucbvax!ucsfcgl!sdcarl!rusty
Newsgroups: net.games.emp
Title: famine
Article-I.D.: sdcarl.294
Posted: Thu May 13 18:39:30 1982
Received: Fri May 14 05:28:47 1982

Here is a shell script that if run on a census report will print
the census report with

(1) the total population in that census

(2) the minimum amount of food for that census for a day

(3) an asterisk at the end of the line if that census is too low

Here it is:

#! /bin/sh

if test $# -lt 1
then
	echo "usage: famine census1 census2 ..."
	exit 1
fi

for file
do
	cat $file | awk ' { if ( NR < 3 ) print }
	{ if ( NR == 3 ) print $0 " pop minf" }
	{ if ( NR > 3 ) {
		pop = $7 + $8
		minf = pop * 0.048
		if ( minf < 1 )
			minf = 1
		warn = ""
		if ( $9 < minf )
			warn = "*"
		printf "%s %3d %4.0f %s\n", $0, pop, minf, warn
	} } '
done