I'm trying to do a complex find and replace in all files through unix command line using the answer provided in find and replace in multiple files on command line but I can't seem to get my find and replace strings escaped properly.
I need to find all lines that contain:
if ($session['test']>0){
and replace it with
if ($session['test']>1){
The command I'm trying is:
find . -name '*.php' |xargs perl -pi -e 's/if\(\$session\[\'test\'\]\>0\){/if\(\$session\[\'test\'\]\>1\){/g'
But that gives me another prompt which requires me to enter an additional '
character because the command tells me there's a string that's missing termination. If I put it in extra '
at the end, I get:
Unmatched ) in regex; marked by <-- HERE in m/if\(\$session\[\test']>0) <-- HERE {/ at -e line 1.
How do I get this replacement to work?