Consider the following folder structure starting in some root folder
/root/
/root/.git
/root/node_modules
/root/A/
/root/A/stuff1/
/root/A/stuff2/
/root/A/node_modules/
/root/B/
/root/A/stuff1/
/root/A/stuff2/
/root/B/node_modules/
...
Now I am in /root
and I'd like to find all my own files inside it.
I have a small number of my own files and the huge number of files inside node_modules
and .git
.
Because of that, traversing node_modules
and filtering it out is unacceptable, as it takes too much time. I want the command to never enter the node_modules
or .git
folder.
For excluding files only directly from the folder of the search:
If you want to exclude certain paths that are in subfolders, you can do that too using
*
wildcard.Say you have
node_modules
too insidestuff1
andstuff2
, and additionallydist
andlib
folders:Tested on Windows using git bash 1.9.5
It seems however it does not work properly on Windows when a filter like
-name '*.js'
is passed. The workaround could be to not use-name
and pipe togrep
instead.Kudos to @Daniel C. Sobral