AWK field seperator question

Larry W. Virden 75046.606 at CompuServe.COM
Fri Feb 16 02:49:15 AEST 1990


I have an awk question.  I am using SunOS 4.0.2 on a Sun 386i.
I want to , within a particular pattern { action }, reset the
Field Seperator, process the current record, then set the FS back
to the default action.

To do this, I tried:
/config/ {
        FS = "\""; print $2 ;
        FS = ""
        next
}

{
        print $1, $2
}

But, when I try this out, it doesnt perform as expected.  I do
get fields 1 and 2 if I dont have a record with config in it.  I do get info without
double quotes if
I type config "this is a test" to it.
But, if I then type another plain line, I don't get back the default
action.

Also, Certain things in the pattern field cause the behavior to change
- like trying to use a field variable in the patter (e.g. $1 ~ /config/).

Can anyone help me?  P{.S.  I have tried this in the version of gawk that I have
anbd it has similar problems there.



More information about the Comp.unix.questions mailing list