From owner-freebsd-questions@FreeBSD.ORG Fri Jan 14 07:47:15 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8472A1065675 for ; Fri, 14 Jan 2011 07:47:15 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 441D88FC19 for ; Fri, 14 Jan 2011 07:47:15 +0000 (UTC) Received: from r55.edvax.de (port-92-195-143-131.dynamic.qsc.de [92.195.143.131]) by mx02.qsc.de (Postfix) with ESMTP id B1F2C1DB37; Fri, 14 Jan 2011 08:47:13 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id p0E7lCu8005030; Fri, 14 Jan 2011 08:47:12 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Fri, 14 Jan 2011 08:47:11 +0100 From: Polytropon To: ws@au.dyndns.ws 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> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org, Robert Bonomi Subject: Re: awk question: replacing "%d%s" by "%d %s" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2011 07:47:15 -0000 On Fri, 14 Jan 2011 17:53:04 +1030, Wayne Sierke 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, ...