$ ruby -e 'puts $ARGF.readlines.reverse' Gennady. > -----Original Message----- > From: Bil Kleb [mailto:Bil.Kleb / nasa.gov] > Sent: Thursday, May 04, 2006 6:22 > To: ruby-talk ML > Subject: Ruby equivalent to simple awk program > > Hello, > > I found this awk snippet in news:comp.lang.fortran this > morning, and it made me realize that I don't use Ruby as a > *nix filter as often as I probably should because I couldn't > duplicate the capability in "about 10 seconds": > > Glen Herrmannsfeldt wrote: > > Here is an awk program that will read in a file line > by line and write the lines out in reverse order. It > will allocate array elements as long as there is still > available memory. Variables are initialized to zero > (or ""), even array elements. > > { array[n++]=$0;} > > END { > while(n-->0) print array[n]; > } > > This took about 10 seconds to write and worked the > first time. > > Later, > -- > Bil > http://fun3d.larc.nasa.gov > >