In Ruby 1.8, how do I delete a tree of directories where some of the subdirectories begin with '.'?
For example, I have an embedded Linux filesystem directory that I want to clean out. One of its subdirectories is ./dev/.udev/files.
Dir[ "{**/*,**/.**,**/.*}" ].sort.reverse.each do | p |
puts p
if ( ( p != '..' ) and ( p != '.' ) ) then
if File.directory? p then
Dir.rmdir p
else
File.delete p
end
end
end
This recognizes ./dev/.udev/, but it won't remove the files (or files and directories) under .udev.
I realize that I could be brutal and execute
system("rm -Rf *")
from the working directory, but I'd like to understand the globbing methodology better.
Thanks in advance! :D