func getNthLine(filename, n) { var file = File(filename) file.open_r.each { |line| Num($.) == n && return line } warn "file #{file} does not have #{n} lines, only #{$.}\n" return nil } var line = getNthLine("/etc/passwd", 7) say line if defined(line)
Last updated 10 months ago