Last active
June 2, 2019 17:19
-
-
Save peiris/4bfe7edd94c76a98f578a228e8418529 to your computer and use it in GitHub Desktop.
Revisions
-
Kasun harshana peiris revised this gist
Jun 2, 2019 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ - Open your terminal. - Browse to your master project directory or the top level of where you have a bunch of projects stored. - Run the command: ``find . -name "node_modules" -type d -prune -exec rm -rf '{}' +`` ####How it works ``find .`` Instructs the find program to search for files in the current directory .. ``-name "node_modules"`` Instructs the find program to search for files named “node_modules”. ``-type d`` Instructs the find program to only look for file directories named “node_modules”. ``-prune`` Instructs the find program to not descend into the current file/directory for it to exclude child “node_modules” directories. On Mac, since -d was specified, -prune has no effect on the find program’s lookup results (per the man pages). However, on Linux, -prune still instructs the find program to not descend into the current file/directory. ``-exec rm -rf '{}' +`` Instructs the find program to execute rm -rf on the matching results. The code '{}' + instructs the command line to be built by appending each selected file name at the end thus invoking the rm -rf command less times than the total number of “node_modules” directory matches. This helps with performance. -
Kasun harshana peiris created this gist
Jun 2, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ - Open your terminal. - Browse to your master project directory or the top level of where you have a bunch of projects stored. - Run the command: `find . -name "node_modules" -type d -prune -exec rm -rf '{}' +` *How it works* `find .` Instructs the find program to search for files in the current directory .. `-name "node_modules"` Instructs the find program to search for files named “node_modules”. `-type d` Instructs the find program to only look for file directories named “node_modules”. `-prune` Instructs the find program to not descend into the current file/directory for it to exclude child “node_modules” directories. On Mac, since -d was specified, -prune has no effect on the find program’s lookup results (per the man pages). However, on Linux, -prune still instructs the find program to not descend into the current file/directory. `-exec rm -rf '{}' +` Instructs the find program to execute rm -rf on the matching results. The code '{}' + instructs the command line to be built by appending each selected file name at the end thus invoking the rm -rf command less times than the total number of “node_modules” directory matches. This helps with performance.