Re: rmdir when directory is not empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 20 Dec 2005, Chasecreek Systemhouse wrote:

On 12/20/05, Mogens Kjaer <mk@xxxxxx> wrote:

That won't work on directories that have tens of thousands of files.

Why not?

As long as you don't do a:

rm -f /dir/folder-with-many-files/*

that, of course won't work, but

rm -rf /dir/folder-with-many-files

should work.


Have you tried it?  rm will fail because the shell cannot keep track
of that many;
the find cmd works because it deals with one file at a time.

Yes. I have done it. On a directory with roughly a million files in it. It took a long time because the old ext2/3 non-indexed directories scale badly performance-wise but completed fine.

The shell has nothing to do with rm beyond invoking the program. If you don't believe me - check the source code for rm for yourself.

The shell only gets involved when you do something like 'rm -rf /dir/folder/*'
where it has to expand the wildcarded parameters before rm is actually
invoked. And then you are correct - the shell will balk if the rsulting list of files is too long for it to cope with.

--
Benjamin Franz

The designer of a new kind of system must participate fully in the implementation.

                                                         - Donald E. Knuth


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux