Awk Field Separators
John Lacey
john at basho.uucp
Thu Aug 23 03:39:57 AEST 1990
In article <1990Aug22.054330.24911 at iwarp.intel.com> of comp.unix.questions
merlyn at iwarp.intel.com (Randal Schwartz) writes:
} In article <3729 at se-sd.SanDiego.NCR.COM>, cubbage at se-sd (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.
}
} There's no easy way to handle it in plain Awk. (Alright everyone, what's
} the next phrase... come along now...) Get Perl.
}
} [ some gross Perl stuff deleted ...]
"There's no easy way to handle it in plain Awk"? Okay, maybe you like Perl
better, but that's no reason to needlessy hose Awk. If by plain Awk you
mean 1977 Awk, fine. But don't get Perl, get New Awk, or GNU Awk.
Then you can type
awk 'BEGIN { FS="[ |]" } ...' ...
or better, with GNU Awk,
gawk -v FS="[ |]" ...
Just another Awk hacker ... :-)
--
John Lacey,
E-mail: ...!osu-cis!n8emr!uncle!basho!john (coming soon: john at basho.uucp)
Voice: (614) 436--3773, or 487--8570
"What was the name of the dog on Rin-tin-tin?" --Mickey Rivers, ex-Yankee CF
More information about the Comp.unix.questions
mailing list