So I have a space/new line after a closing ?> (php tag) that is breaking my application.
How can I find it easily I have 1000 of files and 100000 lin
This is possible with regular grep
grep -Pz '\?>[\s]+$' -Rl
Will search for all files starting from the current directory and list all that have a ?> followed by white space at the end of the file.
-P Interpret the pattern as a Perl-compatible regular expression (PCRE).-z Treats the input file as one long line - this is in part what makes it work [\s]+ matches at least one white space - including newlinesIf you want to match PHP files only:
find -name '*.php' | xargs grep -Pz '\?>[\s]+$' -l
To search for white space at the beginning of the file before
find -name '*.php' | xargs grep -Pz '^[\s]+<\?' -l