2007/9/7, Bulhac Mihai <mihai.bulhac / yahoo.com>:
> how can i read only a line from a txt file?
> for example i want to read only line 3

% cat one_line.rb
#!/usr/bin/env ruby

def read_one_line(file_name, line_number)
  File.open(file_name) do |file|
    current_line = 1
    file.each_line do |line|
      return line if line_number == current_line
      current_line += 1
    end
  end
end

puts read_one_line(ARGV[0], ARGV[1].to_i)

% ruby one_line.rb one_line.rb 3
def read_one_line(file_name, line_number)

-- 
http://pcdavid.net/