From 807c2c3e4f733b43b6b9cd21f085690e6efe514c Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 15 Sep 2007 02:06:16 +0000 Subject: Fix bashism by using find + sort. Speedup scanning by using mail.log and only the single most recent file by default (overridable with logfiles=). --- localshowmailreceived | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 localshowmailreceived (limited to 'localshowmailreceived') diff --git a/localshowmailreceived b/localshowmailreceived new file mode 100755 index 0000000..3d8fe19 --- /dev/null +++ b/localshowmailreceived @@ -0,0 +1,17 @@ +#!/bin/sh +# +# /usr/local/sbin/localshowmailreceived +# Copyright 2007 Jonas Smedegaard +# +# $Id: localshowmailreceived,v 1.1 2007-09-15 02:06:16 jonas Exp $ +# +# List recently received emails +# +# TODO: Handle other indicatiors than AMaViS +# + +logfiles=1 + +find /var/log -name 'mail.log*' | sort -nr -t. -k3 | tail -n "$logfiles" | xargs zcat -f \ + | egrep -- ' -> <'"$1"'@homebase.dk>' \ + | sed 's/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/' -- cgit v1.2.3