Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Created July 6, 2012 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandfoy/3058509 to your computer and use it in GitHub Desktop.
Save briandfoy/3058509 to your computer and use it in GitHub Desktop.
dupes
#!/usr/bin/perl
use File::Find;
use Digest::MD5;
find( \&wanted, grep { -e } @ARGV );
our %digests;
sub wanted {
return if( -d $File::Find::name or -l $File::Find::name );
my $fh;
unless( open $fh, '<', $File::Find::name ) {
warn "$File::Find::name: $!";
return;
}
my $digest = Digest::MD5->new->addfile($fh)->hexdigest;
$digests{$digest} .= "$File::Find::name\000";
}
foreach my $digest ( keys %digests ) {
my @files = split /\000/, $digests{$digest};
next unless @files > 1;
print join( "\n\t", @files ), "\n\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment