Possible Duplicate:
How can I grep in source files for some text?
What's the command to search for specific text in specific file types, recursively, under the current directory?
What's the command to search for specific text in specific file types, recursively, under the current directory? | |||
|
show 1 more comment
feedback
|
This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.
This command runs find on the local directory (.) for any files with names matching the pattern *.extension, then runs grep for "string" on the results of the find. Note that find is inherently recursive. As long as you can differentiate the files that you want from the files you don't based on name, this should work for you. | |||
feedback
|
|
To list the file name, line number in specified file and line the text appears:
It will only run in the current directory, but it will format it nicely for you. | ||||
|
feedback
|
ack-grep, you can use the examples in the question as a started (just like I said), i.e. thefind | xargs | greplines. For the specific output,man grepis always useful to read. – slhck Aug 25 '11 at 21:55grep -r --include=*.<type> "<string>" ., which worked. Unfortunately, the man page is not very straightforward in mentioning the trailing dot. – Phillip Aug 25 '11 at 22:03