#!/bin/sh # funky shell/perl hybrid that seems rather elegent, though a bit obfuscated # stat reference: %Y is mtime, %X is atime # we have new mail if mtime>atime # man 5 mbox says that mail spool should also be non-empty, but I've forgone that check # See RFC2822 for more information if [ -z $1 ]; then echo "Usage: `basename $0` [ []]" echo "If there is new mail in mailspool (mtime is more recent than atime) the new mail message is printed" echo "If the mail in mailspool has been read (no new mail, see above) the read mail message is printed" echo "If no new mail message is given, the default (\"no mail in \") is used" echo "If no read mail message is given, none is used" else file=$1 if [ -z $2 ]; then message="new mail in $file" else message=$2 fi perl -e "if (`stat -c %Y\>%X $file`) { print '$message'; } else { print '$3'; }" fi