Skip to content

Instantly share code, notes, and snippets.

@caugner
Created May 20, 2015 11:58
Show Gist options
  • Save caugner/01c6013270405cf6bd7a to your computer and use it in GitHub Desktop.
Save caugner/01c6013270405cf6bd7a to your computer and use it in GitHub Desktop.
Remove messages from mail queue by recipient
# Adapted from `man postsuper` (in earlier tail versions, one could write the shortcut `tail +2` to skip the first line)
mailq | tail -n +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($8 == "[email protected]" && $9 == "")
print $1 }
' | tr -d '*!' | postsuper -d -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment