Find and list duplicates of files (26)

4 Name: #!/usr/bin/anonymous : 2008-04-26 17:23 ID:Heaven

My version uses File::Find, so I don't have to directly deal with recursion. It pairs up the md5 to the file names. And if there is more than one file for an md5, it prints the file names.

use File::Find;

sub wanted {
push @{$dups{substr(`md5sum -b "$_"`,0,31)}}, $File::Find::name if -f;
}


find \&wanted, ('.');

while (($k,$v) = each(%dups)) {
if (scalar @$v > 1) {
print "$k:";
foreach (@$v) {
print " [$_]";
}
print "\n";
}
}
This thread has been closed. You cannot post in this thread any longer.