Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.unix.questions Subject: Re: AWK Question Summary: split() breaks lines into _fields_ Message-ID: <2308@munnari.oz.au> Date: 5 Oct 89 10:28:52 GMT References: <281@nisca.ircc.ohio-state.edu> Sender: news@cs.mu.oz.au Lines: 24 In article <281@nisca.ircc.ohio-state.edu>, frank@hpuxa.ircc.ohio-state.edu (Frank G. Fiamingo) writes: > BEGIN {FS=""} > {split($0,array); > if (array[28] == " ") {array[28] = 0}; > for(i in array) print array[$1]} > However, it appears that split is only recognizing 2 fields > in the record, rather than the 35 characters that it contains. New versions of awk may be different, but the 4.3BSD manual says "The variable FS ... may be changed at any time to any single character." By experiment, the awk that comes with SunOS 4.0 takes the first character of FS as the only separator. The following script does the trick: BEGIN { n = 28 } { if (substr($0, n, 1) == " ") { print substr($0, 1, n-1) "0" substr($0, n+1, length-n); } else { print; } } Another approach would be to use sed.