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

Re: Too many subdirectories



On Mon, Mar 15, 1999 at 03:11:06PM -0500, Dan Brosemer wrote:
> On Mon, 15 Mar 1999, Sami Dalouche wrote:
> 
> > I made a c program :
> > 
> > #include <stdio.h>
> > main()
> > {
> > int nbr=0;
> > while(1)
> > 	{
> > 	printf("%d\n",nbr+=1);
> > 	mkdir ("x");
> > 	chdir ("x");
> > 	}
> > exit(0);
> > }
> 
> I hate to ask, but... why???  I duplicated this for the sake of making
> sure this script would work, and it brought my system to it's knees.

Because my friend and I wanted to do a little benchmarking to compare the
speed of a bash script and this C script. The bash one is about 100 times
slower, at least ! But, we didn't look too smart after it created over 10,000
subdirectories and that we didn't know how we were going to get rid of them.

> 
> > My problem is that there is now too many subdirectories (10,000) and rm said
> > " Memory exhausted " when I type 
> > rm -rf x
> > Does anyone know of a C script which can suppress all these directories ?
> > Thanks.
> 
> This should do it but it'll take forever
> 
> #!/bin/sh
> while [ -d 'x' ] ; do
>   mv x/x x1
>   rmdir x
>   mv x1 x
> done
> 
> just put that in a text file, chmod it to 755 and run it.
> 
> Good luck.

Thank you, there's a C one from the other person that is a little faster than
the bash, but I never thought of this method.

> 
> -Dano
> 
> 
> -- 
> Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null

-- 
Christophe Clapp      \\  //  cclapp@ifrance.com
   |    |  |\ |  |  |  \\//
   |__  |  | \|  |__|  //\\
                      //  \\  cclapp@easynet.fr    


Reply to: