christian christian - 3 months ago 7x
Linux Question

Recursively find all php files not starting with a comment

Is there any useful combination of commands (sed/grep/find etc.) I can use for detecting .php files not starting with a comment? I could write a little script of course, but I'd rather use shell commands.

Matching pattern:


I'd like searching in the contents of the file, not the file names.

I have to deal with a hacked website where code-injection follows a certain pattern.

<?php $code....




Using gnu grep you can use this recursive search:

grep -Ervlz $'^[[:space:]]*<?php\n/\*' --include='*.php'