0

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.

0

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
  • What does [ -d node_modules ] do? – FreeLightman Jan 16 '17 at 12:34
  • checking if the directory exists. – Ipor Sircer Jan 16 '17 at 12:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.