麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Perl > 正文

fdupe 查找重復文件的Perl腳本代碼

2020-10-31 15:17:01
字體:
來源:轉載
供稿:網友
圖:



復制代碼 代碼如下:

#!/usr/bin/perl
#
# fdupe tool - finding duplicate files
#
# $Id: fdupe,v 1.7 2011/10/14 20:11:21 root Exp root $
#
# Source code Copyright (c) 1998,2011 Bernhard Schneider.
# May be used only for non-commercial purposes with
# appropriate acknowledgement of copyright.
#
# FILE :        fdupe
# DESCRIPTION : script finds duplicate Files.
# AUTHOR:       Bernhard Schneider <[email protected]>
# hints, crrections & ideas are welcome
#
# usage: fdupe.pl <path> <path> ...
#        find / -xdev | fdupe.pl
#
# how to select and remove duplicates:
#   redirect output to >file, edit the file and mark lines you
#   wish to move/delete with a preceding dash (-)
#   Use following script to delete marked files:
#   #!/usr/bin/perl -n
#   chomp; unlink if s/^-//;
#
# history:
# 12.05.99 - goto statment replaced with next
# 14.05.99 - minor changes
# 18.05.99 - removed confusing 'for $y'
#            included hash-search
# 20.05.99 - minor changes
# 02.03.00 - some functions rewritten, optimized for speed
# 10.01.01 - hint-fix by Ozzie |ozric at kyuzz.org|
# 05.03.02 - fixed hangups by reading block/char-Devices
# 08.09.11 - skips checking of hard links
# 14.10.11 - accept file names from stdin
#
#use strict; # uncomment for debugging

$|=1;
local (*F1,*F2); my %farray = (); my $statF1;

# ------------------------------
# traverse directories
sub scan ($) {
    my ($dir) = $_[0];
    opendir (DIR, $dir) or die "($dir) $!:$@";
    map {
          (-d) ? scan ($_) : push @{$farray{-s $_}},$_
             unless (-l or -S  or -p or -c or -b);
    } map "$dir/$_", grep !/^/./.?$/, readdir (DIR); closedir (DIR);
}

# ------------------------------
# get chunk of bytes from a file
sub getchunk ($$) {
  my ($fsize,$pfname) = @_;
  my $chunksize = 32;
  my ($nread,$buff);

  return undef unless open(F1,$$pfname);

  $statF1 = [(stat  F1)[3,1]];
  binmode F1;
  $nread = read (F1,$buff,$chunksize);
  ($nread == $chunksize || $nread == $fsize) ? "$buff" : undef;

# ------------------------------
# compare two files
sub mycmp ($) {
  my ($fptr) = $_[0];
  my ($buffa, $buffb);
  my ($nread1,$nread2);
  my $statF2;
  my ($buffsize) = 16*1024;

  return -1 unless (open(F2,"<$$fptr"));

  $statF2 = [(stat  F2)[3,1]];

  return 0
   if ($statF2->[0] > 1 && $statF1->[1] == $statF2->[1]);

  binmode F2;
  seek (F1,0,0);

  do {  $nread1 = read (F1,$buffa,$buffsize);
     $nread2 = read (F2,$buffb,$buffsize);

     if (($nread1 != $nread2) || ($buffa cmp $buffb)) {
         return -1;
        }
  } while ($nread1);

  return 0;
}

# ------------------------------

print "collecting files and sizes .../n";

if (-t STDIN) {
 $ARGV[0] = '.' unless $ARGV[0]; # use wd if no arguments given
 map scan $_, @ARGV;
} else { 
 while (<STDIN>)  {
  s

主站蜘蛛池模板: 一级毛片大片 | 亚洲骚图 | 免费观看黄视频 | www.精品久久 | 欧美高清一级片 | 91精品国产乱码久 | 国产在线观看一区二区三区 | 羞羞视频在线免费 | 久久久鲁 | 成人在线视频一区 | 777zyz色资源站在线观看 | 色a综合 | 韩国一级免费视频 | 国产一区二区在线免费 | 成片免费观看大全 | 日本精品婷婷久久爽一下 | 久草在线视频网 | 羞羞网站在线看 | gogo全球大胆高清人露出91 | 依依成人精品视频 | 久久免费视频一区 | 性爱网站 | 国产一区二区三区视频在线 | 国产a一级片 | 羞羞视频免费网站男男 | 日韩av影片在线观看 | 免费看成人av | av电影免费观看 | 午夜激情视频免费 | 深夜网站在线观看 | 男女隐私免费视频 | 91经典视频 | 欧美成人三级视频 | 三级国产三级在线 | 在线看成人av | 国产精品一区二区三区在线播放 | 一区二区三区日韩精品 | 一区二区三区视频在线播放 | 一级在线免费观看视频 | 羞羞视频.www在线观看 | 91久久夜色精品国产网站 |