Deleting LARGE number of files

rossman at columbia.edu rossman at columbia.edu
Tue Apr 27 18:25:24 UTC 2004


Quoting Ryan Golhar <golharam at umdnj.edu>:
> Just out of curiousity, why is it a problem to delete a large
> number of files?  What is 'rm' doing?  This sort of sounds like
> a bug in rm.

Not a bug in rm, but more likely, Chris is hitting up against
a shell limit in the number of args that "*" expands to.

Try doing the following in the same directory:

  $ echo *

This will probably get you a similar error, since what the shell
does is to expand the "*" to a list of all matching items in
that current directory, and it does so in the command line of
the shell (invisibly).  Even the shell has its buffer limits.

A better approach would be to recursively delete the directory
from the directory above it, as someone has already described.
If you want to delete the directory 'b' and all of the files
contained in it, and directory 'b' lives under directory 'a'
(e.g. /a/b), then 'cd /a' and 'rm -r b'.  That should do it.

K



> --- Chris <redhat-list at dotcomdesigners.com> wrote:
> > Okay, newbie question - and I can't find the answer
> > on Google...  :-|
> > 
> > How can you delete the contents of a directory that
> > has a HUGE number of files?  By huge I mean when
> > "rm -f *" complains with "too many items" error
> > message.  I don't care what's in there, I just want
> > to wipe it all.





More information about the redhat-list mailing list