From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10ad19,1a7ef15e5c7743b8 X-Google-Attributes: gid10ad19,public X-Google-Thread: f678f,1a7ef15e5c7743b8 X-Google-Attributes: gidf678f,public From: mark@ispc001.demon.co.uk (Mark Katz) Subject: Re: AWK on digital UNIX. Date: 1997/03/06 Message-ID: <857657781snz@ispc001.demon.co.uk>#1/1 X-Deja-AN: 223515709 References: <331DC423.38DB@rpspo2.atlantaga.ncr.com> <857638970snz@ispc001.demon.co.uk> X-Mail2News-User: mark@ispc001.demon.co.uk X-Mail2News-Path: ispc001.demon.co.uk Organization: ISPC Ltd Reply-To: Mark@ispc001.demon.co.uk Newsgroups: comp.unix.osf.misc,comp.lang.awk I posted a reply to this mail which contained incorrect information about awk (sorry awk! - I had just got off a plane from New York > London and was suffering for a sleepless/uncomfortable flight - thanks to American!) gsub does indeed return the number of substitutions it carried out. I tried your program on MKS-DOS-AWK and it replaced each space with the digit '1' - ie a b -> a11b Not that I fully understand why Is that what you got? When I changed it to "'s - ie gsub(" ", "", $2) it worked as desired Mark >In article <331DC423.38DB@rpspo2.atlantaga.ncr.com> > rchannav@rpspo2.atlantaga.ncr.com writes: > >>Recently I had to write a script in awk on DIGITAL - UNIX 4.0. >>I was surprised by this ambiguous output and see if it is the >>way in DIGITAL UNIX. The code segment is as follows >> >>awk -F\, '{ >> gsub(/ /,//,$2) >> print $0 >> }' < /tmp/tmp.txt >> >>the tmp.txt is like this >> >>hello,fo o,123 >>foo,bar,123 >>bar,ba r,123 etc., >> >>Basically I am stripping the blanks from second field. The output it >>produces is in the following format >> >>hello,fo10,123 ****<- do you mean hello,fo1o,123 >>foo,bar,123 >>bar,ba1r,123 >> >>I know that gsub returns the no.of occurences, but why in $2?? -- Mark Katz ISPC, London - Innovation in data-delivery tools Tel: (44) 181-455 4665, Fax (44) 181-458 9554 ** Visit our website on http://www.efiche.com/efiche **