Awk Field Separators
Greg, Ext. 3414
wrightgr at mwk.uucp
Fri Aug 24 18:25:53 AEST 1990
In article <3729 at se-sd.SanDiego.NCR.COM>, cubbage at se-sd.SanDiego.NCR.COM (Sharon Cubbage) writes:
> Does anybody know how to specify more than one field separator in Awk?
> I would like to specify to an Awk program to treat single spaces as well
> as bars as field separators so that a string such as :
>
> 12 12 12 34|34|34
>
> will be said to have 6 fields. I've tried to create a regular expression
> to handle both cases but it hasn't been working.
>
> Any hints?
I haven't found any way to do it either. The manual says it only accepts a
single character. You might try getting a copy of GAWK (Gnu Awk). GAWK allows
regular expressions for the FS variable. For example:
awk 'BEGIN {FS="[ |]"} {print NF}' input.dat
gives a result of 6 for the data above. Awk, however, gives 1 as a result.
It's worth checking out.
Greg Wright <wrightgr at mwk>
uucp: uhnix1!mwk!wrightgr So they tell me. We just got a new feed
so I don't know for sure.
More information about the Comp.unix.questions
mailing list