summaryrefslogtreecommitdiff
path: root/localshowmailreceived
blob: 468f106fdcd618be4af43de940a61fa47a18ede4 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localshowmailreceived
  4. # Copyright 2007 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localshowmailreceived,v 1.3 2007-09-27 21:43:37 jonas Exp $
  7. #
  8. # List recently received emails
  9. #
  10. # TODO: Handle other indicatiors than AMaViS
  11. #
  12. logfiles="${logfiles:-1}"
  13. maildomain=$(if [ -r /etc/mailname ]; then head -n 1 /etc/mailname; fi;)
  14. find /var/log -name 'mail.log*' | sort -nr -t. -k3 | tail -n "$logfiles" | xargs zcat -f \
  15. | egrep -- ' -> <'"$1"'@'"$maildomain" \
  16. | sed 's/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/'