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)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay