Notice: Trying to access array offset on value of type bool in /home/customer/www/ on line 2442
Changing files in a directory structur | Flogvit

Had to help a friend which was moving his site from an “ancient” php version to a new one, where you have to change all the <? to <?php. This had to be done on all sub directories, and only on .html and .php files. I felt a one-liner tingling in my head, so here it is:

find . \( -name "*.html" -o -name "*.php" \) -print | xargs sed -i 's/<? /<?php /gm'

Happy changing.

%d bloggers like this: