I am searching for a class declaration on a site with hundreds of PHP files. How can I do this in the current folder and subfolders using grep?
I tested cding to the folder and then something like
grep -r 'class MyClass' *.php
|
feedback
|
This question came from our site for professional and enthusiast programmers.
|
I'd recommend that you use something like ctags rather than do it with a grep. However, if you want to, you can do something like
This of course assumes that you have just a single space between | |||
|
feedback
|
|
If you use
Note the period on the end of the above. What you told But, if you ever have more than one space after
| |||
|
feedback
|
will search through all the folders with names ending with .php
will search for class MyClass in all files in all sub folders, then only return the ones that have .php in them. | |||
|
feedback
|
|
| |||
|
feedback
|
grep -rdidn't give you. – Jerry Coffin Jan 19 '10 at 16:45