http://qs321.pair.com?node_id=1132227


in reply to Re^2: How do i search and extract commented lines from a file using perl?
in thread How do i search and extract commented lines from a file using perl?

If I understand the problem, you want to find all files beneath a directory which contain a certain string, except ignoring the string when it falls in a comment block. Here's a solution that uses perl:

find . -type f -print0 | while read -d $'\0' f; do if perl -0777pe 's| +/\*.*?\*/||gs' $f | grep certain_string >/dev/null; then echo $f; fi +; done

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.