summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--maildups.sh10
1 files changed, 7 insertions, 3 deletions
diff --git a/maildups.sh b/maildups.sh
index d309e9e..c38467d 100644
--- a/maildups.sh
+++ b/maildups.sh
@@ -3,11 +3,15 @@
maildir=$1
+echo 'Generating Message-ID table...'
msgid_file=`mktemp`
-grep -rH -m1 '^[Mm]essage-[Ii][Dd]:' "$maildir"|sort -n>"$msgid_file"
+grep -rH -m1 '^[Mm]essage-[Ii][Dd]:' "$maildir"| \
+ sed -r 's/(.*):[Mm]essage-[Ii][Dd]:\s*(\S.*)/\2:\1/'| \
+ 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 -fv
+ echo "Removing dups of $msgid"
+ < "$msgid_file" sed -n "s/^$msgid://p"|sed 1d|xargs -d'\n' rm -fv|sed 's/./ &/'
done
-rm -f "$mktemp"
+rm -f "$msgid_file"