Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jan 2011 08:47:11 +0100
From:      Polytropon <freebsd@edvax.de>
To:        ws@au.dyndns.ws
Cc:        freebsd-questions@freebsd.org, Robert Bonomi <bonomi@mail.r-bonomi.com>
Subject:   Re: awk question: replacing "%d%s" by "%d %s"
Message-ID:  <20110114084711.0e76b8c2.freebsd@edvax.de>
In-Reply-To: <1294989784.2037.79.camel@predator-ii.buffyverse>
References:  <20110113062819.4ecb89d9.freebsd@edvax.de> <201101140022.p0E0MIW8029158@mail.r-bonomi.com> <20110114071712.c7a7fe7e.freebsd@edvax.de> <1294989784.2037.79.camel@predator-ii.buffyverse>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 14 Jan 2011 17:53:04 +1030, Wayne Sierke <ws@au.dyndns.ws> wrote:
> I suspect it is a transcription error by Robert in his email.
> 
> From man awk:
> 
>        sub(r, t, s)
>               substitutes t for the first occurrence of the regular
> expression
>               r in the string s.  If s is not given, $0 is used.
> 
> 
> So the correct syntax is:
> 
>         sub("[a-z]", " &", nr)

Works in this version, thanks! Reduction of 7 lines of code.
sub(from, to, where); is the correct form.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110114084711.0e76b8c2.freebsd>