The problem here is normal grep doesn't match multiple lines. So, I would install pcregrep
and try the following command:
pcregrep -rMl '?>[s
]+z' *
This will match all files in the folder and subfolders (the -r
part) using PCRE multiline match (the -M
part), and only list their filenames (the -l
part).
As for the pattern, well that matches ?>
followed by 1 or more whitespace or newline characters, followed by the end of the file z
. I found though, when I ran this on my folder, many of the PHP files do in fact end with a single newline. So you can update that regex to be '?>[s
]+
z'
to match files with whitespace over and above the single
character terminator.
Lastly, you can always use od -c filename
to print unambiguous representation of the file if you need to check its exact character sequence ending.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…