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