Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!n8emr!uncle!basho!john From: john@basho.uucp (John Lacey) Newsgroups: comp.unix.questions Subject: Re: Awk Field Separators Message-ID: <1990Aug22.173957.6441@basho.uucp> Date: 22 Aug 90 17:39:57 GMT References: <3729@se-sd.SanDiego.NCR.COM> <1990Aug22.054330.24911@iwarp.intel.com> Distribution: comp.unix.questions Organization: Sportsware Lines: 37 In article <1990Aug22.054330.24911@iwarp.intel.com> of comp.unix.questions merlyn@iwarp.intel.com (Randal Schwartz) writes: } In article <3729@se-sd.SanDiego.NCR.COM>, cubbage@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@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