Re: extracting value from a field in awk



In article <1183310331.478346.252980@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<new299@xxxxxxxxxxxxxx> wrote:
Hi,

I have lines in a file that look like this:

all_initstring0010010100111000/1dca.rule118.iter100.score
all_initstring0010010100111000/1dca.rule140.iter100.score: 0

I want to extract from these lines the value after rule and before '.'
as well as the third field so for this example I'd get:

.................^^^^^? Sure you don't mean second?

118 140 0

Getting the fields out is trivial in awk but how to I parse the fields
to extract the value I'm looking for?

Thanks for your time, apologies if this is the wrong forum for this
request.


Your description/text is a little murky (unclear what you mean by
"getting ... is trivial but how do I ..." - where both ...s refer to
essentially the same activity).

But, I'm guessing you want something like:

sub(/^.*rule/,"") { print $0+0,$2 }

.



Relevant Pages

  • It could only be them!!!!!!!!
    ... This secure website will ensure all the information we receive cannot be intercepted, ... End of extract ... No prizes for guessing what happens when you try the link. ...
    (uk.gov.agency.csa)
  • Re: decoction for Scotch ale?
    ... I'm guessing the boil does something to the sugars that makes ... could an extract brewer take a portion of ...
    (rec.crafts.brewing)
  • Counting time instances Challenge
    ... This is really hard to explain, and I'm just as unclear as to what I ... I have to extract and manipulate the data I have. ... My problem comes with just realizing what I have to do. ...
    (microsoft.public.excel.misc)
  • Calculate Time Between Two Date/Time Fields
    ... I have the expression using Datediff to extract the hours between two ... date/time fields however, I am unclear on how to exclude Holidays and ...
    (microsoft.public.access.queries)
  • Re: from String to DATE format?
    ... Sorry, it was really unclear. ... What I want is to extract the date from a HTTP header in this format, ...
    (comp.lang.java.help)