#! /bin/sh # usage: uniq-mbox {output_file} # uniq-mbox will remove duplicates from mbox on stdin, # truncate the output_file and put uniq-ified mail there, # tell you the name of the tempfile where it left duplicate emails # me=`basename $0` date=`date +%Y%m%d-%H%M%S` uniqfile=$1 if test -z "$uniqfile"; then echo "usage: $me {output_file}" 1>&2 exit 1 fi : > $uniqfile status=$? if test $status != 0; then echo "$me Error: could not truncate output file $uniqfile" 1>&2 exit 1 fi procmailrc=`tempfile --prefix=pmrc` dupfile=`tempfile --prefix=dups` cachefile=`tempfile --prefix=cache` trap "rm -f $procmailrc $cachefile" TERM INT cat > $procmailrc <&2 echo "duplicates are in $dupfile" 1>&2 sh -xc "rm -f $procmailrc $cachefile"