: # mailgrep - grep mail messages for patterns # Heiner Steven (heiner.steven@odn.de), 6/96 # # Uses non-standard feature of the "agrep" command. # Determine user name. Example "id" output: uid=1064(heiner) gid=100(entw) : ${USER:=`expr "\`LANG=C id\`" : 'uid=[0-9]*(\([^)]*\).*'`} for MailBox in /var/mail/$USER /usr/spool/mail/$USER "" do [ -r "$MailBox" ] && break done [ -z "$MailBox" ] && exec echo "cannot determine mailbox" # Grep for pattern within whole messages, not within single lines exec agrep -d'^From ' "$@" "$MailBox"