I'd like to find all files that contain a certain string of text. How would you do that in the Terminal?

link|improve this question

68% accept rate
If you want a fast result, use Spotlight, though. Also if you want to find files that don't necessarily store text directly within the file such as PDF or ODF. – Joey Jul 13 '10 at 9:47
Good advice, but in my case I'm not sure the files are indexed since they are on network drivers. And also they are xml files belonging to a particular program. – Svish Jul 13 '10 at 10:09
feedback

2 Answers

up vote 8 down vote accepted
grep -r 'text goes here' path_goes_here
link|improve this answer
Awesome simple answer. Thanks! – Svish Jul 13 '10 at 9:51
Congrats on your 10K. – Dennis Williamson Jul 13 '10 at 14:31
feedback

use spotlight

mdfind "text goes here"
mdfind -onlyin /home/user/Desktop -live "live update"

don't forget to look at:

man mdfind
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.