From: Robert Klemme Date: 2004-04-19T17:54:08+09:00 Subject: Re: Delete a directory with all sub-directories an files "Kristof Bastiaensen" schrieb im Newsbeitrag news:4082752a$0$973$a0ced6e1@news.skynet.be... > On Sat, 17 Apr 2004 20:53:48 +0200, Dirk Einecke wrote: > > > Hi. > > > > I would like to delete a directory. In this directory are other > > directories an files. So I have to delete this subdirectories an files > > at first. Now I search a good solution to solve this problem. My first > > idea was to look in the given directory and if there are subdirectories > > to look in this directories... Is this the right way? Is there a ready > > function for this little problem? Or has anybody written a function for > > it? > > > > greetings > > Dirk Einecke > > `rm -rf directory` > :-) Another one liner would be: Dir[File.join(dir, '**', '*')].reverse.each {|f| (File.directory? ? Dir : File).delete f} :-) Note: this one is portable also. robert