From: Josh Cheek Date: 2012-09-08T16:40:11+09:00 Subject: Re: awk equivalent in ruby --bcaec517a9d4783b8704c92bd5ec Content-Type: text/plain; charset=ISO-8859-1 On Fri, Sep 7, 2012 at 4:56 AM, Brian Candler wrote: > Josh Cheek wrote in post #1075006: > > 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 > > Josh has assumed that these are pairs of lines. I think this was just an > artefact of formatting by the OP's mail client, and they are really > single lines. In that case you just want the 4th column of each line: > > ruby -ane 'puts $F[3]' < f > > Oh, you're probably right. This was submitted via Ruby Forum, which does wrap lines IIRC. No wonder the data was so confusing >.< Is this a setting someone could turn off? I think it is objectively incorrect to wrap lines for people. Their display software (in my case, Gmail) should be responsible for determining the presentation settings (line width), not the input source. The input source (Ruby Forum) has no idea, and is making incorrect assumptions about my display, which is causing problems. --bcaec517a9d4783b8704c92bd5ec Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, Sep 7, 2012 at 4:56 AM, Brian Candler <lists@ruby-forum.com= > wrote:
Josh Cheek wrote in post #1075006:
> 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.4= 6.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
>
>
> $ ruby -ane 'puts $F[2] if /^=3D INTEGER: /' < f
> 1
> 1
> 1
> 1
> 1
> 1
> 1
> 1

Josh has assumed that these are pairs of lines. I think this wa= s just an
artefact of formatting by the OP's mail client, and they are really
single lines. In that case you just want the 4th column of each line:

ruby -ane 'puts $F[3]' < f

= =A0
Oh, you're probably right. This was submitted via Ruby Fo= rum, which does wrap lines IIRC. No wonder the data was so confusing >.&= lt;

Is this a setting someone could turn off? I think it is objectively inc= orrect to wrap lines for people. Their display software (in my case, Gmail)= should be responsible for determining the presentation settings (line widt= h), not the input source. The input source (Ruby Forum) has no idea, and is= making incorrect assumptions about my display, which is causing problems.<= br>
--bcaec517a9d4783b8704c92bd5ec--