Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to search recursively for files containing a string. I want to search:

  1. Files in and under the directory I'm standing in currently
  2. A specific directory.

I want to see only results. I don't want to see "permission denied" messages or other things. Only the file locations that contain the string I search for.

How do I do it?

share|improve this question
up vote 4 down vote accepted

grep -lr searchstring * /path/to/dir 2>/dev/null

share|improve this answer
Using . instead of * will include hidden files in the current directory as well, not just in the subdirectories. – Daniel Andersson May 22 '12 at 18:19
Were using grep -r | sed s/:.*//. – uprego Sep 4 '14 at 8:18

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.