From: Brian Candler Date: 2012-09-07T18:56:44+09:00 Subject: Re: awk equivalent in ruby 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 -- Posted via http://www.ruby-forum.com/.