Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1149468
  • 博文数量: 312
  • 博客积分: 12522
  • 博客等级: 上将
  • 技术积分: 3376
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-27 18:35
文章分类

全部博文(312)

文章存档

2016年(3)

2015年(1)

2013年(1)

2012年(28)

2011年(101)

2010年(72)

2009年(13)

2008年(93)

分类: IT业界

2011-07-13 23:21:08

#在c:\查找findfile.pl文件

#!/usr/bin/perl -w
use strict;
use File::Find;

sub wanted {
if ($_ eq "findfile.pl") {
            print $File::Find::name;
}
}

find (\&wanted,'c:/');


#在c:\下删除所有以.temp结尾的文件

#!/usr/bin/perl -w
use strict;
use File::Find;

sub wanted {
if (-f $File::Find::name) {
        if ($File::Find::name=~/\.temp$/) {
        print "Removing $File::Find::name\n";
        unlink $File::Find::name;
}
}
}
find (\&wanted,'c:/');
 
#!/usr/bin/perl -w
use strict;
use File::Find;
print "Starting to clean all \.keep file in current directory:\n";
sub wanted {
if (-f $File::Find::name) {
        if ($File::Find::name=~/\.keep$/) {
        print "Removing $File::Find::name\n";
        unlink $File::Find::name;
}
}
}
find (\&wanted,'c:/','d:/','e:/');
阅读(853) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~