title: Unix recursive find / replaced based on dynamic pattern?
body: <p>So, I inherited some really bad code and am currently just trying to refactor it to the point of functionality before completely overhauling it.  One of the problems is that the original programmer set posts and sessions like this:</p>
  
  <pre><code>$_SESSION[somename]  
  $_POST[somevar]
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>$_SESSION['somename']
  $_POST['somevar']
  </code></pre>
  
  <p>It seems to be causing problems throughout the site.  Is there a fast way that I can recursively find and replace these types of variables? I'm using a unix box, so not sure if there's a way to do that from the command line or if I should write a php script? They're everywhere and obviously are named different, so I would need to find any variable that does not have the quotes and replace it with the same string that does?</p>