rmdir when directory is not empty

Jeff Vian jvian10 at charter.net
Tue Dec 20 20:47:57 UTC 2005


On Tue, 2005-12-20 at 15:31 -0500, Gene Heskett wrote:
> On Tuesday 20 December 2005 13:20, Chasecreek Systemhouse wrote:
> >> OR rm -fr /dir/dir-delete-me
> >
> >That won't work on directories that have tens of thousands of files.
> >--
> >WC -Sx- Jones | http://ccsh.us/ | Open Source Consulting
> 
> Oh?  That must mean that all those kernel src dir leftovers I've 
> cleaned over the years are still around then.  But I can't find them.
> 
> The pony trick is to use, as root, rm -fR name-of-directory
> 
FWIW I have seen several times the failure of a command when using
globbing to create the filelist.  If the list of files is large enough
(in the tens or maybe even hundreds of thousands) the shell hits a limit
where it cannot process the list.

I can confirm it is the globbing because when I encountered this I was
able to move down the directory tree and remove various pieces using the
same command. After *trimming* the tree I was later able to remove the
entire thing. I simply had to do that in pieces instead of all at once.
In my case something had filled the drive (I never found what had
misbehaved so) so there were no remaining free inodes with many
thousands of tiny files.

IIRC it had to do with the number of files at a single level that caused
the globbing to barf.  I also have not had a directory of that size for
more than 4 years so I have not encountered it with more current
software.  This limitation may/may not still be there.

> For a built kernel tree, it takes about 10-12 seconds on an XP2800 
> athlon, and I'd imagine there are well over 5000 files in that tree 
> once built.  But gone they are.  Note that the last time I read the 
> manpage on rm, the uppercase and lowercase R/r's had different 
> meanings.
> 




More information about the users mailing list