Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
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

2 Answers 2

up vote 47 down vote accepted
grep -r 'text goes here' path_goes_here
share|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

use spotlight

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

don't forget to look at:

man mdfind
share|improve this answer
Will this work for files that spotlight doesn't index (i.e. files inside hidden folders, system config files, etc)? –  Accipheran Sep 10 '13 at 4:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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