Advertisement
ZaxonXP45

find_duplicates.pl

Oct 13th, 2022 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.54 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. my ($one, $two, %data) = ("", "", );
  7.  
  8. my @list = qx/find .. -iname '*.7z' -exec 7z l -slt {} \\;/;
  9.  
  10. foreach (@list) {
  11.  
  12.     $one = $1 if (/Path = (.*\.7z)/);
  13.     $two = $1 if (/Path = (.+\.[^(7z\n)]+)/);
  14.  
  15.     if (/7-Zip/) {
  16.  
  17.         if (exists $data{$two}) {
  18.  
  19.             printf("DUP: %s\n%s\n", $data{$two}, $one);
  20.  
  21.         } else {
  22.  
  23.             $two =~ s#^\./##;
  24.  
  25.             $data{$two} = $one;
  26.         }
  27.     }
  28. }
  29.  
  30. foreach my $key (sort keys %data) { printf("%s\n", $key) }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement