Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!lobster!mwk!wrightgr From: wrightgr@mwk.uucp (Greg, Ext. 3414) Newsgroups: comp.unix.questions Subject: Re: Awk Field Separators Message-ID: <3353@mwk.uucp> Date: 24 Aug 90 08:25:53 GMT References: <3729@se-sd.SanDiego.NCR.COM> Distribution: comp.unix.questions Organization: M. W. Kellogg, Houston TX Lines: 23 In article <3729@se-sd.SanDiego.NCR.COM>, cubbage@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 uucp: uhnix1!mwk!wrightgr So they tell me. We just got a new feed so I don't know for sure.