Skip to content

Instantly share code, notes, and snippets.

@avin
Created June 17, 2015 12:19
Show Gist options
  • Save avin/7a7fe5d60c748cd7eaf6 to your computer and use it in GitHub Desktop.
Save avin/7a7fe5d60c748cd7eaf6 to your computer and use it in GitHub Desktop.
Search mail-chain in maillog by email
#/bin/sh
EMAIL=$1
MAILLOG_FILE=/var/log/mail/maillog
if [[ $EMAIL =~ "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+" ]]; then
cat $MAILLOG_FILE | grep $EMAIL | awk -F": " '{print $2}' | grep -v "NOQUEUE" | xargs -I{} sh -c "grep {} $MAILLOG_FILE --color=auto; echo '-----------------------'"
else
echo "Use like: mailfind [email protected]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment