Grep through an entire folder

find text within a bunch of files within a folder simply by typing this:

grep -nr 'whatever' .

Where r is recursive, and n gives you the line number. 🙂

Advertisements

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