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=). --- localshowmailreceivedfromdomain | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'localshowmailreceivedfromdomain') diff --git a/localshowmailreceivedfromdomain b/localshowmailreceivedfromdomain index a671408..d83f394 100755 --- a/localshowmailreceivedfromdomain +++ b/localshowmailreceivedfromdomain @@ -3,11 +3,15 @@ # /usr/local/sbin/localshowmailreceivedfromdomain # Copyright 2007 Jonas Smedegaard # -# $Id: localshowmailreceivedfromdomain,v 1.1 2007-09-15 01:53:15 jonas Exp $ +# $Id: localshowmailreceivedfromdomain,v 1.2 2007-09-15 02:06:16 jonas Exp $ # # List emails recently received from a certain domain # # TODO: Handle other indicatiors than AMaViS # -(zcat /var/log/syslog.{7,6,5,4,3,2,1}.gz; cat /var/log/syslog) | egrep -- '@'"$1"'> -> ' | sed 's/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/' +logfiles=1 + +find /var/log -name 'mail.log*' | sort -nr -t. -k3 | tail -n "$logfiles" | xargs zcat -f \ + | egrep -- '@'"$1"'> -> ' \ + | sed 's/^\(.\{15\}\) [^)]*) \([^,]*\), [^]]*] \([^ ]*\) -> .*Message-ID: \([^>,]*>\?\).*/\1 \3 (\4) \2/' -- cgit v1.2.3