find . -name node_modules -exec rm -rf {} +
Beware: this removes folders without confirmation. Use only if necessary!
To make the command ask for confirmation before deleting folders, simply add the -i
flag for the rm
command: rm -rfi
.
find
command finds files and folders matching conditions..
is the target folder to search in: the current folder-name node_modules
will match files or folders with the exact name "node_modules"-exec ... {} +
executes some command, replacing the {}
with as many path names as possible for the executed command (in this example rm -fr
)