diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-28 01:50:25 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-28 01:50:25 -0500 |
commit | bc871dbc38d4e1729bfe8696bac0eb86b4d8b7b8 (patch) | |
tree | ac44a9fd627df6af11dbf8341016e84428829a18 | |
parent | af58e68243f3b6b10d7dd177f54c55c3f379ee92 (diff) |
write maildups
a tool to delete duplicate emails in a mailder based on the Message-ID
header
-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 |