Skip to content

Instantly share code, notes, and snippets.

@sushicodeur
Last active August 29, 2015 14:26
Show Gist options
  • Save sushicodeur/f629562ff1e77a67c796 to your computer and use it in GitHub Desktop.
Save sushicodeur/f629562ff1e77a67c796 to your computer and use it in GitHub Desktop.

Trouver les fichiers terminant par un tag de fermeture php suivi d’espaces ou de lignes vides

D’un coup le site ne parvient plus à rendre les fichiers XML générés, sous prétexte que le fichier commence par des lignes blanches en début de fichier.

La cause est connue, mais trouver le coupable à la main est fastidieux. Cette commande permet de faire la liste des fichiers php susceptibles d’insérer ces lignes blanches en début de fichier.

pcregrep -rMl '\?>[\s\n]+\n\z' * > php_file_ending_with_blank_lines

Le résultat est écrit dans le fichier php_file_ending_with_blank_lines

Inspiré de http://stackoverflow.com/questions/6126554/find-extra-space-new-line-after-a-closing-php-tag

# This command reports files ending with ?> followed by empty lines
pcregrep -rMl '\?>[\s\n]+\n\z' * > php_file_ending_with_blank_lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment