Text file line counter : each line « File Directory « Ruby






Text file line counter


line_count = 0
File.open("text.txt").each { |line| line_count += 1 }
puts line_count

 

Related examples in the same category

1.collect the lines together