Originally Posted by GoTerpsGo
Strangely I can't seem to google for a satisfactory answer or for one that works.
I recently inherited a set of Apache web servers that have a bunch of virtual host config files and I want to find one containing the string "mgh". These config files are spread across multiple directories and I have no way of contacting my predecessor as to where the file may be. I found some posts advocating use of Perl for search and replace; I found another one using grep with a bunch of options (it didn't work). Is there a concise way of doing this down many levels from a parent directory?
If you have one directory, with a bunch of subs under it, and want to search all the .config files for "mytext":
cat `ls -alR *.config` | grep -H mytext > output.txt
Should leave you with an output.txt file, with grep results and file names (I think the -H is correct...not looking at the grep man page right now...).
Also note those are backticks (key to the left of the 1 on the keyboard), NOT single-ticks (on the key with the double-quotes).