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
|
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 |
|||
|
|
|
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
|
|||
|
|
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. |
|||
|
|
|
|
|||
|
|
|
In case the matched files might have arbitrary names, you should consider using
|
|||
|
|
grep -rdidn't give you. – Jerry Coffin Jan 19 '10 at 16:45