-1

I am trying

grep -rn '*.cpp' -e 'aPattern'

to find the pattern aPattern recursively in a directory withing cpp files but I got

*.cpp no such file or directory

why is this failing? there are cpp files in the subdirectories

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • 1
    Does this answer your question? [How do I grep recursively?](https://stackoverflow.com/questions/1987926/how-do-i-grep-recursively) – matt Apr 21 '20 at 02:18

1 Answers1

0

found a solution

grep -rn --include '*.hpp' -e 'aPattern'

the key is to put --include

even better

grep --color -rn --include '*.hpp' -e 'aPattern'
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150