Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!amanue!oglvee!norm From: norm@oglvee.UUCP (Norman Joseph) Newsgroups: comp.unix.questions Subject: Re: Awk Field Separators Message-ID: <596@oglvee.UUCP> Date: 23 Aug 90 13:55:12 GMT References: <3729@se-sd.SanDiego.NCR.COM> <1990Aug22.054330.24911@iwarp.intel.com> Distribution: comp.unix.questions Organization: Oglevee Computer Systems, Connellsville, Pa Lines: 32 In <1990Aug22.054330.24911@iwarp.intel.com> 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? >| [...] so that a string such as : >| >| 12 12 12 34|34|34 >| >| will be said to have 6 fields. [...] >There's no easy way to handle it in plain Awk. (Alright everyone, what's >the next phrase... come along now...) Get Perl. >[...] What's so hard about: BEGIN { FS = "[ ]|[|]" } other than the fact that it requires the newer version of awk, as distributed with 5.3 (on this Altos, running 5.3, it's called ``nawk''). This makes single blanks and single bars field separators. If you want to allow multiple spaces or bars, use "[ ]+|[|]+". If you want to collapse multiple occurences of bars or spaces as a single field separator use "[ |]+". >Just another Perl [book] hacker, Just another Perl wannabe (Mebbe someday when I have the time...) :-) -- Norm Joseph cgh!amanue!oglvee!norm@dsi.com Oglevee Computer Systems, Inc. {pitt,cgh}!amanue!oglvee!norm "Shucking Usenet oysters in pursuit of a pearl." -- Bill Kennedy