I have a directory that was generated by mistake by an application and this directory has a structure that involves more than 2000 directories, one inside a another, something like:
Directory aaaa inside bob inside ccc inside ddd inside eee etc. These are 1000 levels deep and many of these directories have names where spaces are URL encoded (spaces are %20 and > are %3E etc).
If I try to remove that directory using rm -fr I get the message directory is not empty. I think the string necessary to remove a directory is too long for UNIX. Is there a way to delete this directory with rm?
I am on Mac OS X Mountain Lion.


type -a rm? – jordanm Jan 13 at 21:07findcommand instead. First confirm the syntax usinglsinstead ofrmto make sure that you get the output you expect, which should be a list of the files you want to delete. Because of the size of the directory you are dealing with, terminate the command early withCtrl+Cand scan the output:find -d /path/to/file -exec ls {} \;If everything looks good, then swap out thelsforrm -rfand hopefully the directory will be removed:find -d test -exec rm -rf {} \;– Michael Yasumoto Jan 13 at 22:01