# Description # search in mailer logs for mails directed to the specified user # # Author: Massimo Gravino (gravino@pd.infn.it) # URL: http://www.pd.infn.it/~gravino/computing/scripts/maillog_parser # if [ -z "$1" ] ; then echo "Usage: $0 e-mail [log-file]" exit fi if [ -z "$2" ] ; then logfile=/var/log/maillog elif [ -f "$2" ] ; then logfile="$2" else echo "File $2 not found." exit fi ids=`grep "$1" "$logfile"|awk '{print $6}'` for id in $ids ; do to=`grep -w $id "$logfile"|grep " to="| awk '{print $7}'` if [ "$to" ] ; then from=`grep -w $id "$logfile"|grep " from="|awk '{print $7}'` date=`grep -w $id "$logfile"|grep " from="|awk '{print $1,$2,$3}'` fi if [ "$to" -a "$from" ] ; then echo $date $from $to fi done