Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Watch a log and/or search for a certain term

If you're developing on a server that has all PHP errors turned off, you can still watch the error log (if you have access to this file). For example on a dreamhost account you could try this:

tail -f /home/account/logs/website.com/http/error.log

As the errors pour in, you will see them come by. Change 'account' to the username you have on dreamhost and website.com to the domainname you host there. If the errors come in large amounts you can filter them by using grep:

tail -f /home/account/logs/website.com/http/error.log | grep -i "search_term"


Now only errors containing 'search_term' will be shown.

Find files with a certain extension, where the files contain a certain search term

Searches the current directory and deeper for files ending with the 'php' extension, where the file itself contains 'search_term'. Useful if you're searching a large website with lots of images and you only want to find a certain function or variable.

find ./ -type f -name \*.php -exec grep -il "search_term" {} \;
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS