Use Grep To Find Text In Folders

This is post is now quite old and the the information it contains may be out of date or innacurate.

If you find any errors or have any suggestions to update the information please let us know or create a pull request on GitHub

Sometimes it can be really hard to figure out exactly which file a chunk of code is coming from. At times like this the command line tool grep is immensely useful.

This snippet of code will search all php files within a specified folder. It will check through all files and sub folders for the string id=“something”


find /path/to/root/search/folder/ -name "*.php" -print0 | xargs -0 grep 'id="something"'

Tags: grep