From: tamouse mailing lists Date: 2012-11-07T11:15:48+09:00 Subject: Re: putting values in one lines Ok, well, pure ruby: lines = IO.readlines(file) lines.each do |l| if l.match(/up\s+down\s+aenet/) print l.split[5], " " end end print "\n" On Tue, Nov 6, 2012 at 7:37 PM, tamouse mailing lists wrote: > If you're hoping to do a pure ruby implementation of this, heed the others. > > If you just need the values, here's the awk: > > awk 'BEGIN { ORS="" } /up.*down.*aenet/ { print $6 }' file... > > or, > > awk -v ORS='' '/up.*down.*aenet/ { print $6 }' file... > > (you don't need the cat or either grep) > > > On Tue, Nov 6, 2012 at 4:21 PM, Ferdous ara wrote: >> Hi, >> Dont know how to explain this. >> >> example , i am doing this >> >> output=`cat #{file} | grep "up down" | grep "aenet" | awk '{print >> $6}'` >> puts output >> >> >> So i get this >> ae40.0 >> ae30.0 >> >> But i want to output like ae40.0 ae30.0 >> >> how can i achieve this ?? >> >> Thanks for your help. >> >> -- >> Posted via http://www.ruby-forum.com/. >> >