summaryrefslogtreecommitdiff
path: root/maildups.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-11-28 01:50:25 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-11-28 01:50:25 -0500
commitbc871dbc38d4e1729bfe8696bac0eb86b4d8b7b8 (patch)
treeac44a9fd627df6af11dbf8341016e84428829a18 /maildups.sh
parentaf58e68243f3b6b10d7dd177f54c55c3f379ee92 (diff)
write maildups
a tool to delete duplicate emails in a mailder based on the Message-ID header
Diffstat (limited to 'maildups.sh')
-rw-r--r--maildups.sh11
1 files changed, 11 insertions, 0 deletions
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