8
find .   -name "DIR-NAME" -type d -delete

because i want to delete specific dir name recursively well it returns

find: cannot delete `./DIR-NAME': Directory not empty

which is expeted but I have no idea how to make -delete to delete non-empty dirs here as i can with rm -rf

Braiam
  • 35,991
user240891
  • 81
  • 1
  • 1
  • 2

2 Answers2

8

Like this :

find . -name "DIR-NAME" -type d -exec rm -r {} +
1

Before you delete directories, you could delete files. ie first run:

find .   -name "DIR-NAME" -type f -delete

Might not work if you have special file types.

Andy
  • 389
  • 1
    Wow, sure missed that argument. I'd suggest then " find . -name "DIR-NAME" -type d -exec rm -rf {} ';'" and I'll see myself out. – Andy Dec 23 '14 at 21:17
  • ITYM something like LC_ALL=C find . '(' -path '*/DIR-NAME/*' -o -name DIR-NAME -type d ')' -delete. – Stéphane Chazelas Mar 15 '23 at 17:40