#! /usr/bin/gawk -f # Last edited on 2003-10-12 12:30:27 by stolfi # Reads the output of `ls -Abs1 --block-size=1 /var/spool/mail' # executed twice 1000 seconds apart, and prints a list showing # the (estimated) total mail received by each user in that interval. BEGIN { split("", msize); split("", mrecv); } (NF != 2){ printf "NF = %d: \"%s\"\n", NF, $0 > "/dev/stderr"; next; } /^total/{ next; } ($2 ~ /[^a-z0-9]/) { next; } /./ { sz = $1; uid = $2; if ((uid in msize) && (sz > msize[uid])) { mrecv[uid] += (sz - msize[uid]); } msize[uid] = sz; } END { tot = 0; for (uid in mrecv) { printf "%9d %s\n", mrecv[uid], uid; tot += mrecv[uid] } printf "\n%9d TOTAL\n", tot; }