From: Robert Dober Date: 2007-04-28T16:04:25+09:00 Subject: Re: Output A File w/ Line Numbers? On 4/27/07, John Joyce wrote: > I'd like to read a file and output its contents (just to terminal is > fine for simplicity) with line numbers. > Is there a Ruby library method that handles this like unix cat? > Of course we can write a looping one-liner, but it seems to me this > function must already exist. > > love, > John Joyce > > ARGF.readlines.each_with_index{ | line, idx | puts "%3d %s" % [ idx.succ, line ] } HTH Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw