0

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?

John
  • 7,343
  • 23
  • 63
  • 87

2 Answers2

5
$ grep
Usage: grep [OPTION]... PATTERN [FILE]...

so

grep fred *

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

By using -r you are explicitly requesting recursion.

user9517
  • 115,471
  • 20
  • 215
  • 297
2

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.

jftuga
  • 5,731
  • 4
  • 42
  • 51