lis = `ls` lil = lis.split(/\n/) lil.each{|i| File.delete(i) if FileTest.size?(i) == nil }