Search git for line of code

Any branch, any commit, here’s how you search for a line of code in Git.

git log -S '$this->isTheCodeIAmLookingFor();' --all --source -- path/to/file/to/check.php  

This will return the commit number and branch.

Find and Replace a line of text automatically using sed

Now that my VM is completely configured through puPHPet’s puphpet/files/exec-once shell scripts, I had to change PHP settings for the legacy 5.3 install. At first I echoed the setting out and concatenated it onto the end of the string, however the setting was already uncommented above.

The answer is to use sed to find and replace the line of text, like this!

cat /etc/php.ini | sed -e "s/short_open_tag = Off/short_open_tag = On/" >> /etc/php.ini