From: Hassan Schroeder Date: 2013-02-14T08:49:46+09:00 Subject: Re: file size of each item in file list On Wed, Feb 13, 2013 at 3:08 PM, Sloan Ruby wrote: > This is what I have now. I am not able to print out each line of the > file /tmp/lg_files. There is no output. What am i missing? > File.read("/tmp/lg_files") do |f| > contentsArray=[] # start with an empty array > f.each_line {|line| > #a = contentsArray.push line > b = File.size contentsArray.last > puts b > } > end You've commented out the contentsArray.push line which insures that it's always empty, for one thing :-) Regardless, you don't need that at all. Something like this: File.open("/tmp/lg_files","r").readlines.each do |line| line.chomp!; puts "#{line} #{File.size(line)}" end should do what you want with fewer moving parts. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com http://about.me/hassanschroeder twitter: @hassan