# output of "md5" is one line per file: "MD5 (filename) = signature" find . -type f -print0 | xargs -0 md5 | perl -ne '/MD5 \((.*)\) = (\S+)/ or next; ($f,$m)=($1,$2); $s=-s $f; if($h{"$m $s"}){unlink $f} $h{"$m $s"}++'