How do I do the equivalent of a Unix rm -rf directory
command?
(This is for a GNU/Linux box.)
Thanks,
···
–
Bil Kleb
NASA Langley Research Center
Hampton, Virginia, USA
How do I do the equivalent of a Unix rm -rf directory
command?
(This is for a GNU/Linux box.)
Thanks,
–
Bil Kleb
NASA Langley Research Center
Hampton, Virginia, USA
“Bil Kleb” W.L.Kleb@larc.nasa.gov wrote in message
news:3D186E3A.3B9747FF@LaRC.NASA.Gov…
How do I do the equivalent of a Unix
rm -rf directory
command?(This is for a GNU/Linux box.)
I’m curious, rm -rf will just as well work for a GNU/Linux box, so I guess
you don’t simply want to execute this as a shell command from your Ruby
script with rm -rf <dir>
?
Paul
“Paul E.C. Melis” wrote:
I’m curious, rm -rf will just as well work for a GNU/Linux box, so I guess
you don’t simply want to execute this as a shell command from your Ruby
script withrm -rf <dir>
?
Right, for some reason I’m against using system or back ticks today.
–
Bil
Hi,
I’m curious, rm -rf will just as well work for a GNU/Linux box, so I guess
you don’t simply want to execute this as a shell command from your Ruby
script withrm -rf <dir>
?Right, for some reason I’m against using system or back ticks today.
dirs =
Dir.glob(“#{path}/**/{.[^.],…?,}*”) do |f|
if File.directory?(f)
dirs << f
else
File.unlink(f)
end
end
dirs.reverse_each(&Dir.method(:rmdir))
At Tue, 25 Jun 2002 23:34:40 +0900, Bil Kleb wrote:
–
Nobu Nakada
How about FileUtiles.rm_rf in fileutils.rb?
http://cvs.ruby-lang.org/~knu/cgi-bin/cvsweb.cgi/~checkout~/rough/lib/fileutils.rb?rev=1.2
Regards,
TAKAHASHI ‘Maki’ Masayoshi E-mail: maki@rubycolor.org
Bil Kleb W.L.Kleb@larc.nasa.gov wrote:
I’m curious, rm -rf will just as well work for a GNU/Linux box, so I guess
you don’t simply want to execute this as a shell command from your Ruby
script withrm -rf <dir>
?Right, for some reason I’m against using system or back ticks today.
It is kind of weird that there is a Dir.delete method that throws an
exception when the dir isn’t empty, but that there isn’t a Dir method that
allows you to delete one that isn’t. Isn’t that overly cautious?
Paul
nobu.nokada@softhome.net wrote in message
news:200206251559.g5PFxmp05227@sharui.nakada.kanuma.tochigi.jp…
Hi,
I’m curious, rm -rf will just as well work for a GNU/Linux box, so I
guess
you don’t simply want to execute this as a shell command from your
Ruby
At Tue, 25 Jun 2002 23:34:40 +0900, > Bil Kleb wrote:
script with
rm -rf <dir>
?Right, for some reason I’m against using system or back ticks today.
dirs =
Dir.glob(“#{path}/**/{.[^.],…?,}*”) do |f|
if File.directory?(f)
dirs << f
else
File.unlink(f)
end
end
dirs.reverse_each(&Dir.method(:rmdir))–
Nobu Nakada
Hi,
At Wed, 26 Jun 2002 19:33:55 +0900, Paul E.C. Melis paul@floorball.nl wrote:
It is kind of weird that there is a Dir.delete method that throws an
exception when the dir isn’t empty, but that there isn’t a Dir method that
allows you to delete one that isn’t. Isn’t that overly cautious?
The code will try to remove all files other than directory
first.
–
Nobu Nakada