Awk Field Separators
Mark Harrison
harrison at necssd.NEC.COM
Wed Aug 29 04:33:56 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.
The new version of Awk (nawk) can do this, but the old version can't.
$ echo "a b,c" | nawk -F",| " '{print NF}'
3
$ echo "a b,c" | awk -F",| " '{print NF}'
2
--
Mark Harrison harrison at necssd.NEC.COM
(214)518-5050 {necntc, cs.utexas.edu}!necssd!harrison
standard disclaimers apply...
More information about the Comp.unix.questions
mailing list