0

I'm trying to to grep through all the files within a certain directory. Is there a way to recursively list all directories & the files/directories within them via something like ls?

Hays Stanford
  • 93
  • 1
  • 8

1 Answers1

3

Try the -r option for grep. Here is a reference: https://linuxize.com/post/how-to-use-grep-command-to-search-files-in-linux/#recursive-search.

The search matches list out the path to the files that match your pattern as well. Should be easy to extract that out using something like cut

synaptikon
  • 699
  • 1
  • 8
  • 16
  • 1
    Awesome. This answers the question better than the suggested duplicate post found here: https://stackoverflow.com/questions/1987926/how-do-i-grep-recursively – Hays Stanford Jan 27 '20 at 19:17