I want to find directory 'node_modules' in the current directory. But I do not need nested 'node_modules'. For example, I do not need 'node_modules' in 'node_modules', only parents. When the directories are found, I want to delete them.
1 Answer
Check for directory exist then delete.
[ -d node_modules ] && rm -rf node_modules
You can skip checking and use only rm
:
rm -rf node_modules