Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 usually use grep word * while being in a folder which includes files that have that word. But in this folder i also have folders which under them there are files that have that word, what is the correct command for this matter please?


share|improve this question
up vote 5 down vote accepted

There's a recursive option to grep:

grep -R word *

You can replace "*" with a full path to a directory that you want to look at as using a wildcard will search for the word "word" in current directory.

share|improve this answer
i feel so lame for not trying -R :( thanks dude – Itai Ganot Dec 26 '12 at 17:16
find . -type f | xargs grep -l "search-pattern" 


grep -R "search pattern" *
share|improve this answer
When used right, grep -R can save hours. For example, I was editing a JSP application, and needed to find the file related to a web page I was seeing. A quick copy-and-paste of one HTML line into grep, and the related file appears in the terminal. Not recommended for larger applications, or slow machines ;) – Soviero Dec 26 '12 at 15:35

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.