ok so what I am trying to do is search through 200k files that have ext .000 or .702. for *@yahoo.com.tw and if it finds that in the file. then remove the file. this is my code... what am i doing wrong. it seams it will only find
asdflkajsdf@yahoo.com.tw as a string and not *@yahoo.com.tw so it will not rm the file.
#!/usr/bin/perl
# This will recursively look for files with extension .702 or .000, starting
# at the path specified ./phil /var/files/i/hate
# if yahoo.tw if found in any of these files, the file will be removed
# try it a few times, then uncomment the rm line to make it really go to work
use strict;
use warnings;
my @file_extensions = ('702', '000');
my $search_string = "yahoo.com.tw";
my $match;
if ($ARGV['0'] ne "")
{
foreach (@file_extensions)
{
my @bad_files = `find $ARGV['0'] -name \\*\.$_`;
foreach (@bad_files)
{
print "Evaluating $_\n";
$match = system("grep -i $search_string $_");
if ($match == 0)
{
#`rm -f $_`;
print "Removed $_\n";
}
}
}
}
else
{
print "I need to know where you want me to start files.... \n
IE:./phil /var/studpid_files/";
}