Re: rmdir when directory is not empty

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

 



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.

--
WC -Sx- Jones | http://ccsh.us/ | Open Source Consulting

$ cd
$ mkdir bigdir
$ cd bigdir
$ mkdir anotherdir
$ touch anotherdir/afile
$ ls anotherdir
afile
$ cp -p ../makefiles.c .
$ cat makefiles.c
#include <stdlib.h>
#include <stdio.h>

#define NUM_FILES   10000

int     main(void) {
    int     FileNum;
    char    TouchFile[20];

    for (FileNum = 0; FileNum < NUM_FILES; FileNum++) {
        sprintf(TouchFile,"touch file%08d",FileNum);
        if (system(TouchFile) == -1) {
            printf("oops: %s\n",TouchFile);
            return EXIT_FAILURE;
        }
    }
    return EXIT_SUCCESS;
}
$ gcc -o makefiles makefiles.c
$ ./makefiles
$ ls | head
anotherdir
file00000000
file00000001
file00000002
file00000003
file00000004
file00000005
file00000006
file00000007
file00000008

$ ls | tail
file00009992
file00009993
file00009994
file00009995
file00009996
file00009997
file00009998
file00009999
makefiles
makefiles.c

$ ls | wc
  10003   10003  130033

$ cd
$ rm -r bigdir
$ ls bigdir
ls: bigdir: No such file or directory

Works for me, with 10002 files and one directory with
a file under it.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


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

  Powered by Linux