We can use the find
command to delete a specific directory recursively. This is the command formula:
|
|
For example, if we wanted to delete all node_modules
directories within the path /projects/javascript/
, we would run:
|
|
I noticed sometimes the output says:
find: ./node_modules: No such file or directory
But the command should still work.
If you look closely, we’re really just executing a command against all node_modules
directories in the /projects/javascript/
directory (rm -rf
). This command can be modified to execute other commands against all node_modules
directories, but that is out of the scope of this post :)