Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all files with white spaces the after php tag

Is it possible with linux commands to List all files with white spaces the after php tag at the end of file?

like image 764
Mithun Sreedharan Avatar asked Oct 18 '25 15:10

Mithun Sreedharan


1 Answers

Answer using pcregrep which will match even if your whitespace spans onto new lines:

pcregrep -rM '\?>[\s]+[^\S]*$' *.php

Untested though because I don't have pcregrep installed on this computer. Please correct me if you know it to be incorrect.

This should match all files that end with ?> followed by only whitespace. If it's followed by any other character, then it won't match (e.g. if it's not an all-PHP file and needs ?>)

like image 70
Maccath Avatar answered Oct 21 '25 06:10

Maccath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!