This website recently got a major rebuild; if you're missing something, let Lorna know.

Exclude a Directory when Grepping



As a developer-of-another-discipline who is now transitioning into a bunch of NodeJS projects, I grep a LOT. However I am usually only interested in the code in the project at hand, and not the dependencies - of course grep has a switch for that! To grep your project and not the dependencies in the node-modules folder, try this:

grep -R --exclude-dir node_modules [what to search for] *

If you're using a different tech stack you may want to exclude a different directory (for PHP, the directory would be called vendor), but this is a very handy tip and a bit nicer than the older approach I was using which did the whole search and then used a second grep to eliminate things by using the -v switch.


In: tech
Tags: #grep #nodejs #tips