Ok, more compact:

output = []
IO.readlines("data").map{|l| output << l.split[5] if
l.match(/up\s+down\s+aenet/) }
puts output.join " "


On Tue, Nov 6, 2012 at 8:15 PM, tamouse mailing lists
<tamouse.lists / gmail.com> wrote:
> 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
> <tamouse.lists / gmail.com> 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 <lists / ruby-forum.com> 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/.
>>>
>>
>