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)

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay