From: Josh Cheek Date: 2012-09-07T16:00:20+09:00 Subject: Re: awk equivalent in ruby --f46d0435c072217fc604c91729f5 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Sep 5, 2012 at 2:19 PM, Ferdous ara wrote: > HI > how to use awk equivalent in ruby > > in bash i can use , awk to get the value 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.48.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.49.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.47.48.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.47.49.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.47.48.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.47.49.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.47.48.46.51.50.55.54.56 > = INTEGER: 1 > > RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.47.49.46.51.50.55.54.56 > = INTEGER: 1 > > This question was asked in a very confusing way, I didn't realize `= INTEGER: 1` was part of the input, I thought it was the result you expected to get after doing some sort of analysis on the line above it. Anyway, to expand on Brian's answer: $ cat f FC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.48.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.49.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.47.48.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.47.49.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.47.48.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.47.49.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.47.48.46.51.50.55.54.56 = INTEGER: 1 RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.47.49.46.51.50.55.54.56 = INTEGER: 1 $ ruby -ane 'puts $F[2] if /^= INTEGER: /' < f 1 1 1 1 1 1 1 1 --f46d0435c072217fc604c91729f5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Sep 5, 2012 at 2:19 PM, Ferdous ara <lists@ruby-forum.com= > wrote:
HI
how to use awk equivalent in ruby

in bash i can use , =A0awk to get the value 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.48.= 46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.49.= 46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.= 47.48.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.= 47.49.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.= 47.48.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.= 47.49.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.= 47.48.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.= 47.49.46.51.50.55.54.56
=3D INTEGER: 1


This question was asked in a very confusing way, = I didn't realize `=3D INTEGER: 1` was part of the input, I thought it w= as the result you expected to get after doing some sort of analysis on the = line above it.

Anyway, to expand on Brian's answer:

$ cat f
FC1155-SMI::= enterprises.2636.3.40.1.4.1.2.1.3.1.13.118.99.112.45.48.47.48.46.51.50.55.5= 4.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.= 13.118.99.112.45.48.47.49.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.9= 9.112.45.48.47.48.47.48.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI:= :enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.48.47.48.47.49.46.51.= 50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.9= 9.112.45.49.47.48.47.48.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI:= :enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.49.47.48.47.49.46.51.= 50.55.54.56
=3D INTEGER: 1
RFC1155-SMI::enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.9= 9.112.45.50.47.48.47.48.46.51.50.55.54.56
=3D INTEGER: 1
RFC1155-SMI:= :enterprises.2636.3.40.1.4.1.2.1.3.1.15.118.99.112.45.50.47.48.47.49.46.51.= 50.55.54.56
=3D INTEGER: 1


$ ruby -ane 'puts $F[2] if /^=3D INTEGER: /&#= 39; < f
1
1
1
1
1
1
1
1
--f46d0435c072217fc604c91729f5--