rmdir when directory is not empty
Paul Howarth
paul at city-fan.org
Tue Dec 20 18:39:30 UTC 2005
Chasecreek Systemhouse wrote:
> On 12/20/05, Mogens Kjaer <mk at crc.dk> 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.
The shell never sees the big list, only rm does. That was the point the
previous poster was making.
One thing that "rm -rf" won't handle though, is directories that you
don't have write permission on. Try this:
$ mkdir -p fred/jim/sheila
$ chmod 555 fred/jim
$ rm -rf fred
rm: cannot remove directory `fred/jim/sheila': Permission denied
This can be fixed using chmod:
$ chmod -R a+rwx fred
$ rm -rf fred
(success!)
Paul.
More information about the fedora-list
mailing list