You didn't specify whether you wanted an easy way or a hard way.  If
you want a hard way, hack the following recursive perl script to only
remove *.class.

 

#!/usr/local/bin/perl
use English;


sub delete_directory_tree {
    my($dir) = shift;
    my($path);
    unless (opendir(DIR, $dir)) {
        warn "Can't open $dir\n";
        closedir(DIR);
        return -1;
    }
    foreach (readdir(DIR)) {
        next if $ARG eq '.' || $ARG eq '..';
        $path = "$dir/$ARG";
        if (-d $path) {         # a directory
            &delete_directory_tree($path);
            print "removing directory $path\n";
            (rmdir $path) 
                or (warn "Can't delete $path\n", 
                    return -1);
        } elsif (-f $path) {     # a plain file
            print "removing file $path\n";
            (unlink $path) 
                or (warn "Can't delete $path\n",
                    return -1);
        }
    }
    closedir(DIR);
    return 0;
}

Reply via email to