From: "Peña, Botp" Date: 2007-09-07T17:28:40+09:00 Subject: Re: read a specific line from a file From: Bulhac Mihai [mailto:mihai.bulhac@yahoo.com] # how can i read only a line from a txt file? # for example i want to read only line 3 you can open the file and then read each line, collecting the lines you want. exit anytime if you have what you want. if you want a ready-made solution (written in ruby, of course), you can use rio. irb(main):005:0> require 'rio' => true # get first 4 lines (as always in ruby indexing starts at 0) irb(main):006:0> rio('test.txt').lines[0..3] => ["1testing \n", "2testing \n", "3asdfasdf\n", "\n"] # get first lines 4 to 6 irb(main):007:0> rio('test.txt').lines[3..5] # a range of lines => ["\n", "4asdf\n", "[]\n"] # thus, reading line 3 would be irb(main):013:0> rio('test.txt').lines[2..2] => ["3asdfasdf\n"] kind regards -botp