Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!xylogics!bu.edu!nntp-read!adb From: adb@cs.bu.edu (Adam Bryant) Newsgroups: comp.unix.questions Subject: Re: Awk Field Separators Message-ID: Date: 25 Aug 90 21:21:09 GMT References: <3729@se-sd.SanDiego.NCR.COM> <3353@mwk.uucp> Sender: news@bu.edu.bu.edu Distribution: comp.unix.questions Organization: Boston University Lines: 26 In-reply-to: wrightgr@mwk.uucp's message of 24 Aug 90 08:25:53 GMT In article <3353@mwk.uucp> wrightgr@mwk.uucp (Greg, Ext. 3414) 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. I use the split() command when handling multiple field separators. Code to print a list of fields separated by a ' ' or a '|' is: { for (i = 1; i <= NF; i++) { num = split($i, nstr, "|"); for (j = 1; j <= num; j++) { print( nstr[j] ) } } } Hope this helps. adam bryant