July 13, 2010 | In: Coding Tips

Recursively search and replace content of files

I have encountered a problem when moving an old website to a newer server. Older website was using ‘HTTP_POST_VARS’ which is deprecated in PHP5 and there were thousands of files included older version variable. Here’s the solution using  regular expression to swap ‘HTTP_POST_VARS’ to ‘_POST’ in all files under current & sub directories.

find ./ -type f | xargs perl -pi -w -e 's/HTTP_POST_VARS/_POST/g;'

* Or you can change the php.ini file (register_long_arrays=off) to use the deprecated long predefined variables, though it's not recommended.

Comment Form

Categories

Calendar

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930