Delete Directories Recursively in MacOS and Linux
To delete directories recursively, run the following command while replacing /path/goes/here/
and directory_name
as needed:
|
|
For example, if we wanted to delete all node_modules
directories within the path /projects/javascript/
, we would run:
|
|
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 directories, but that is out of the scope of this post :)