rmdir when directory is not empty

Tony Nelson tonynelson at georgeanelson.com
Tue Dec 20 22:28:44 UTC 2005

At 12:37 PM -0600 12/20/05, Mike McCarty wrote:
>Chasecreek Systemhouse wrote:
>> On 12/20/05, kebbelj at scripting-solutions.com
>> <kebbelj at scripting-solutions.com> wrote:
>>>In the GUI, I can trash a non-empty directory with a right-click and
>>>Move to Trash. What command line option would I use with rmdir to remove
>>>a non-empty directory?
>> The best way to nuke a directory is -
>> # Delete the files.
>> su - -c "find /path/to/dirName -type f -exec rm -f {} \;"
>$ rm -fr /path/to/dirName
>is far safer. It won't work if there is a directory with
>too many files in it, in which case the find will work.

I don't know what "too many files" is, but I've tried it with 200,000 files
in a directory (see thread "Max Files Per Directory" on or about 16 July).
A "rm -rf manyfilestest" took about 3 1/2 minutes for 200,000 files.  (512
MB RAM,.1.2 GHz Athlon)

>But to do it as root! Man, not for the faint-hearted!
>I rarely do anything as root. I've used
># rm -fr /path/to/dirName
>before, but I've always, always, always looked away from the screen,
>and then looked back, at least twice, carefully reading the

I like to do a "ls /path/to/dirName", then use the bash history (up arrow)
to recall the command, press Home, Delete, Delete, and type "rm -rf" on the
front of the path I just listed.
TonyN.:'                       <mailto:tonynelson at georgeanelson.com>
      '                              <http://www.georgeanelson.com/>

More information about the fedora-list mailing list