Forum Moderators: bakedjake
Say the directory is /www/htdocs/domain then do :
locate *.php¦grep /www/htdocs/domain
make sure that give you the list you need and not more (add a ¦more at the end if you have many, as you likely do). This should show you .php file in that directory and subdirectories
Once satisfied those are the files you want to remove :
rm `locate *.php¦grep /www/htdocs/domain`
This does require that the locate db is up to date. If not, run this as root first :
locate -u
There's probably easier ways and if so, someone will likely point it out.
#!/usr/bin/perl -w
use File::Find;
sub rm();
@directories = ("/home/dir1", "/home/dir2");
find(\&rm, @directories);
sub rm() {
my ($filename) = $_;
if ($filename =~ /\.php$/) {
unlink($File::Find::name);
# $File::Find::dir contains the current directory
# $File::Find::name contains the complete path name (dir + filename)
# $_ or $filename contains the filename alone.
}
}
Ps. This is a mod of a script I found a few weeks back on the DevShed forums, works for me, but I would recommend testing it on some fluff dirs first to make sure it doesn't go haywire and delete the wrong files or something.