From: Shashank Date Date: 2004-03-11T06:50:07+09:00 Subject: Re: Novice question, tranlate awk code to ruby code This may not match the terseness of the awk script and is certainly not the only way in Ruby, but is still a one-liner (which may get mis-formated by the email client): C:\RB>type junk.dat 10 20 30 20 30 40 50 60 70 80 90 40 C:\RB>type junk.dat | ruby -ne "p $_.split(' ').slice(0..1).collect{|e| e.to_i}.inject(1){|p,n| p*n}" 200 600 3000 7200 C:\RB>ruby -v ruby 1.8.0 (2003-08-04) [i386-mswin32] --- Horacio Castellini wrote: > Hi everyone: > I'm a novice ruby user, but ancient user in > Linux world. We assume > have a data file with two data field in two columns. > In awk program when I > like time them a script code may be: > > { > print $1*$2 > } > > for example I can use "% cat foo.dat|awk -f > times.awk" d'accorde. Well, > how can I do this in ruby code? > > Thanks Horacio > __________________________________ Do you Yahoo!? Yahoo! Search - Find what you�re looking for faster http://search.yahoo.com