#!/bin/sh tmp=${TMPDIR-/usr/tmp}/plot.$$ trap 'rm "$tmp"; exit' 0 1 2 3 15 < ${1-assn2.grades} awk ' { if ($1 in grade) { print "Duplicate grade for " $1 | "cat >&2" exit 1 } if ($2 > 100 || $2 < 0) { print "Illegal grade for " $1 " of " $2 | "cat >&2" exit 1 } grade[$1] = $2 } END { for (student in grade) { slot = int(grade[student] / 10); if (slot == 10) slot = 9; bar[slot]++; } for (slot = 0; slot < 10; slot++) { print 0+bar[slot]; } }' > "$tmp" case $? in 0) ;; *) exit;; esac gnuplot << EOF set terminal pbm set output "grade.plot.ppm" plot "$tmp" with boxes quit EOF ppmtogif < grade.plot.ppm > grade.plot.gif