Skip to content

Instantly share code, notes, and snippets.

@kentatogashi
Created September 6, 2018 06:26
Show Gist options
  • Save kentatogashi/304b58dcd4e29bafb1f278fce2ed388a to your computer and use it in GitHub Desktop.
Save kentatogashi/304b58dcd4e29bafb1f278fce2ed388a to your computer and use it in GitHub Desktop.
easy_postcat.sh
#!/usr/local/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
TYPE="$1"
CNT=1
SAMPLING_NUM=50
postqueue -p | tail -${SAMPLING_NUM} | awk '{print $1}' | egrep '^[A-Z0-9]{11}' | while read QUEUE_ID;
do
echo "queue: $CNT"
if [ "$TYPE" = --detail ]
then
postcat -q $QUEUE_ID
else
postcat -q $QUEUE_ID | egrep '(recipient:|Received:|Subject:)'
fi
echo
let ++CNT
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment