DEV Community

Julien Prugne for Webeleon

Posted on • Edited on

How to print every file (with the line number) containing a pattern?

While editing a massive codebase, massive like a monorepo with 247 sub projects...

I need to find every file containing a certain pattern.
Webstorm is, once again, indexing... It will finish in 15 minutes....

Let's use a good'ole grep command.

grep --exclude-dir={node_modules,dist,build} -rnw $(pwd) -e 'my secret pattern'

It will print every absolute file path followed by the line number inside the file and the line containing the pattern.

Have fun!

Top comments (0)