DEV Community

Julien Prugne for Webeleon

Posted on • Edited on

1

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more