From: jbw Date: 2010-03-23T00:19:40+09:00 Subject: Re: Reading contents of all files from a Directory Also might want to check if it is a file and skip directories: puts Dir["/*"].map { |f| if(!File.directory?(f)) then File.read f end } But yes this isn't necessarily efficient or safe. On Mon, Mar 22, 2010 at 2:55 PM, Robert Klemme wrote: > 2010/3/21 Jonathan Nielsen : >>> arr = Dir.open("K:/test").entries >>> arr.each do |file| >>>  File.open(file) do |fd| >>>    # do whatever you need with the file >>>  end >>> end >>> >> >> Wow, I typoed that bad, but I hope you get the idea.  (corrected above.) > > If it is only for output purposes, we can actually do it in one line: > > puts Dir["K:/test/*"].map {|f| File.read f} > > Note: this is not necessarily efficient nor safe (just think of 3GB files...). > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > > -- jbw