Учитывая, что файл css может иметь многострочные определения классов, и что в одном и том же файле может быть несколько вхождений, я бы поспорил, что perl - это то, что нужно.
Например:
#input: css filename , and css class name without dot (in the example, ExampleClass)
my ($filen,$classn) = @ARGV;
my $out = findclassuse($filen,$classn);
# print filename and result if non empty
print ("===== $filen : ==== \n" . $out . "\n") if ($out);
sub findclassuse {
my ($filename,$classname) = @_;
my $output = "";
open(my $fh, '<', $filename) or die $!;
$/ = undef; # so that i read the full file content
my $css = <$fh>;
$css =~ s#/\*.*?\*/# #g; # strip out comments
close $fh;
while($css =~ /([^}{]*\.$classname\b.*?{.*?})/gs) {
$output .= "\n\n" . $1;
}
return $output;
}
Но это не на 100% надежно, есть некоторые проблемы с комментариями, и разбор CSS, безусловно, не идеален.