From: dblack@... Date: 2007-07-02T04:54:15+09:00 Subject: Re: awk regexp search ---2049402039-1075790531-1183319657=:19510 Content-Type: MULTIPART/MIXED; BOUNDARY="-2049402039-1075790531-1183319657=:19510" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---2049402039-1075790531-1183319657=:19510 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Sun, 1 Jul 2007, Robert Dober wrote: > On 7/1/07, dblack@wobblini.net wrote: >> Hi -- >>=20 >> On Sun, 1 Jul 2007, baptiste Augui=E9 wrote: >>=20 >> > Hi, >> > >> > The last bit of a bash program is still resisting me. Here is the code= I=20 >> used >> > before: >> > >> > awk '/scattering efficiency/{print $4}' ../OUTPUTFILES/Output.dat >> > >> > >> > How would you do that in Ruby? I just need to locate this regexp in th= e=20 >> file, >> > and get the following value in the same line. I've tried something lik= e, >> > > >> $ ruby -ne 'puts $1 if /scattering efficiency\s+(\S+)/' >> scattering efficiency blah >> =3D> blah >> nothing >> this has scattering efficiency just like the other one >> =3D> just >>=20 > The problem is that we have no idea where "scattering efficency" is > relatively to $4 :( He said "the following value", so I assumed it would be a \S+ match after a \s+ match. > However > > ruby -ane 'puts $F[3] if /scattering efficency/' ../ton/beau/fichier > > does the same as the awk script above Wow -- I really must brush up on 'man ruby' :-) David --=20 * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) ---2049402039-1075790531-1183319657=:19510-- ---2049402039-1075790531-1183319657=:19510--