Removing a directory that isn't empty

What would be the best way to use Dir.rmdir to delete a directory
that isn’t empty? I think it would involve performing a recursive
delete, this is trivial in bash, but what about in Ruby?

Many thanks

Gabriel D.

Gabriel D. wrote:

What would be the best way to use Dir.rmdir to delete a directory that
isn’t empty? I think it would involve performing a recursive delete,
this is trivial in bash, but what about in Ruby?

FileUtils.rm_rf should do the trick.

Gabriel D. wrote:

What would be the best way to use Dir.rmdir to delete a directory
that isn’t empty? I think it would involve performing a recursive
delete, this is trivial in bash, but what about in Ruby?

Many thanks

Gabriel D.

Dear Friends,
I am having one best idea to removing the empty directory.
You have to remove the directory while checking the directory size.
and also while putting the du -sh itself we can do .It is a easy method
to remove the directory.
Somebody might have asking the question before itself.
Plese you could go and see all the questions.In somewhere you will get
the idea for this.

by
vellingiri.

Gabriel D. wrote:

What would be the best way to use Dir.rmdir to delete a directory that
isn’t empty? I think it would involve performing a recursive delete,
this is trivial in bash, but what about in Ruby?

I normally use FileUtils for that sort of thing, e.g.,

require ‘fileutils’
FileUtils.rm_rf ‘directory’

Regards,