summaryrefslogtreecommitdiff
path: root/maildups.sh
blob: d5521da2817185a5a3a0de5445cebe324d30a5d7 (plain)
1
2
3
4
5
6
7
8
9
10
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