Ruby和SHELL中如何遍历指定目录的文件
#!/usr/bin/rubydef traverse(path)
if File.directory?(path)
puts "Dirs:" + path
Dir.foreach(path) do |file|
if file != "." and file != ".."
traverse(path + "/" + file)
end
end
else
puts "Files:" + path
end
end
traverse("d:/vmware")
页:
[1]