- [root@bogon gongzuo]# cat -n search.pl
- 1 #!usr/bin/perl
- 2 use strict;
- 3 use warnings;
- 4 my $dir = "/home/gongzuo";
- 5 opendir DH, $dir or die "Cannot open $dir: $!";
- 6 foreach my $file ( readdir DH ) {
- 7 next if ( $file eq '.' );
- 8 next if ( $file eq '..' );
- 9 if ( $file =~/shell/ ) {
- 10 unlink $file; linux系统里删除是rm,perl 删除用unlink,
- 11 }
- 12 }
- 13 closedir DH;