Skip to content

Instantly share code, notes, and snippets.

@kosztik
Last active December 23, 2019 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosztik/582728386ff462eaff7e0e24adf016d0 to your computer and use it in GitHub Desktop.
Save kosztik/582728386ff462eaff7e0e24adf016d0 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Use: email-i.sh /var/log/mail.info <from/to pattern>
# Used with postfix
if [[ $1 =~ gz ]]; then
cat="zcat"
else
cat="cat"
fi
id=`$cat $1| grep $2|grep -o "Queue-ID: *.........."|cut -d' ' -f2`
for i in $id
do
#cat /var/log/mail.info| grep $i| grep --color from| awk '{ print $0 }'
#cat /var/log/mail.info| grep $i| grep --color spam| awk '{ print $0 }'
$cat $1| grep $i| awk '{ print $0 }'
echo ========================================================================================
echo ========================================================================================
echo ========================================================================================
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment