diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | maildups.sh | 11 |
3 files changed, 13 insertions, 0 deletions
@@ -8,6 +8,7 @@ e emacsmail emacsterm hangman +maildups newegg offlineimap-runner ord @@ -14,6 +14,7 @@ BINFILES = \ emacsmail \ emacsterm \ hangman \ + maildups \ newegg \ offlineimap-runner \ ord \ diff --git a/maildups.sh b/maildups.sh new file mode 100644 index 0000000..d5521da --- /dev/null +++ b/maildups.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Delete duplicate messages in $1 based on the Message-ID header + +maildir=$1 + +msgid_file=`mktemp` +grep -rH -m1 '^[Mm]essage-[Ii][Dd]:' "$maildir"|sort -n>"$msgid_file" + +< "$msgid_file" sed 's/:.*//'|uniq -d|while read msgid; do + sed -n "s/^$msgid://p"|sed 1d|xargs -d'\n' rm -f +done |