Our blog

 

Use Grep To Find Text In Folders

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"

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

More...

More Reading:

One Comments

joseph
April 10th, 2009

If you are using Ubuntu and you fancy a GUI instead, check out search monkey..

This seems to work really well, is very fast and allows you to go straight to editing the file in your favourite text editor (which for me is Geany).

 

 

Leave a Reply