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 want to run the grep -r pattern ./ but WITHOUT recursively going through the sub directories. When I removed the -r flag, I didn't get any output in my terminal. What flag am I supposed to use to grep for patterns in files in my current directory only?

share|improve this question
up vote 5 down vote accepted
$ grep
Usage: grep [OPTION]... PATTERN [FILE]...


grep fred *

will look for fred in the files in the current directory.

By using -r you are explicitly requesting recursion.

share|improve this answer

grep pattern *

also try: grep -l patter * to see which files matched

if you didn't get any output, that means no matches were found.

share|improve this answer

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.