I can't get FileUtils to delete a directory

Hi there,
I created a test folder with two sub-folders inside and now I want to
delete the main folder.
In irb I typed:
require ‘fileutils’
FileUtils.rm_f(“test”)

I’m running the command from C: and the folder is directly off C:
I assumed it should just delete but nothing’s happening…
I know Dir.delete won’t delete a folder if there is something in it. I
want to figure out how to delete the folder in one command rather than
having to go through it deleting all the sub folders one by one. I’m
sure there’s a way to do this?

On Wed, Dec 1, 2010 at 12:59 PM, Tara K. [email protected]
wrote:

Hi there,
I created a test folder with two sub-folders inside and now I want to
delete the main folder.
In irb I typed:
require ‘fileutils’
FileUtils.rm_f(“test”)

This is similar to the command line version on unix systems, where
removing a directory recursively require the -r option. The same
applies here. Use rm_rf instead of rm_f.

FileUtils.rm_rf(‘test’)

Regards,
Ammar

Great that worked thanks a lot…

On Wed, Dec 1, 2010 at 1:19 PM, Tara K. [email protected]
wrote:

Great that worked thanks a lot…

Great! Now where’s my /usr/bin? Just kidding. :wink:

Cheers

robert

I don’t get it…

(newbie - sorry)
But I do know one

A SQL query walks up to a table in a bar and says ‘mind if I join you?’

On 12/1/2010 8:39 AM, Tara K. wrote:

I don’t get it…

(newbie - sorry)

rm -rf has a history of being accidentally used to clobber very
important data from a Unix system. If you’re running as the root user
on Unix, you have the ability to wipe out the entire filesystem,
including the operating system’s files, rather than just your personal
home directory and any other limited directories to which you have write
access. Under older systems, you needed to have the password for the
root user in order to operate in its name. Thus, to really f**k things
up, you need root’s password. :slight_smile:

The moral of the story is to use rm -rf and any similar facility such as
FileUtils.rm_rf with extreme caution.

-Jeremy

hahaha :wink:

On Wed, Dec 1, 2010 at 4:17 PM, Robert K.
[email protected] wrote:

On Wed, Dec 1, 2010 at 1:19 PM, Tara K. [email protected] wrote:

Great that worked thanks a lot…

Great! Now where’s my /usr/bin? Just kidding. :wink:

That’s an educational joke. Reminds me of: “to err is human, to really
f**k things up requires the root password.”

Cheers,
Ammar