AWK field seperator question

Sun Visualization Products matthew at sunpix.East.Sun.COM
Sun Feb 18 07:22:43 AEST 1990


In article <"900215154914.75046.606.CHD39-1"@CompuServe.COM> 75046.606 at CompuServe.COM (Larry W. Virden) writes:
]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
]}

    Leave the field seperator alone, and try using the split function.

                            n = split(s, arr, sep)

n = number of resultant elements
s = the string to be disected
arr = the name of the array to place the elements
sep = the seperation character

    In your example I would do:

 /config/ { split($0, LINE, "\"); print LINE[2] }



-- 
Matthew Lee Stier                            |
Sun Microsystems ---  RTP, NC  27709-3447    |     "Wisconsin   Escapee"
uucp:  sun!mstier or mcnc!rti!sunpix!matthew |
phone: (919) 469-8300 fax: (919) 460-8355    |



More information about the Comp.unix.questions mailing list