Created
June 17, 2015 12:19
-
-
Save avin/7a7fe5d60c748cd7eaf6 to your computer and use it in GitHub Desktop.
Search mail-chain in maillog by email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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