#!/bin/sh -e # Print to stdout a list of duplicate messages in a maildir. cd "$1" test -e cur f=/tmp/flag.$$ mkdir $f trap 'echo >&2 cleaning up; rm -r /tmp/flag.$$' 0 find cur new -type f | while read fn ; do if grep -q -i '^message-id:' $fn ; then : else echo >&2 "no-id $fn" continue fi sum=`grep -i '^message-id:' $fn | md5sum - | awk '{print $1}'` if [ -e $f/$sum ] ; then echo >&2 "$fn is dup of `cat $f/$sum`" echo $fn else echo $fn >$f/$sum fi done