linux n00b

Finding Duplicates based on Filename

Posted in General by downforce on June 22, 2010

Found this brilliant snippet utilising Perl to find duplicates based on filename only, not comparing size (fdupes wins this!)

Full credit goes to radoulov, a member of forums and cursory link to post in thread

perl -MFile::Find -e'
  $d = shift || die "$0 dir\n";
  find { 
    wanted => sub {
      -f and push @{$u{$_}}, $File::Find::name;
    }, $d;
  @{$u{$_}} > 1 and printf "found %s in: \n\n%s\n\n", 
    $_, join $/, @{$u{$_}} for keys %u;    
  ' <dirname>