From owner-freebsd-questions@FreeBSD.ORG Thu Jan 13 05:28:22 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 A76071065695 for ; Thu, 13 Jan 2011 05:28:22 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id 6A8018FC1B for ; Thu, 13 Jan 2011 05:28:22 +0000 (UTC) Received: from r55.edvax.de (port-92-195-143-131.dynamic.qsc.de [92.195.143.131]) by mx01.qsc.de (Postfix) with ESMTP id D3E2A3CFEE for ; Thu, 13 Jan 2011 06:28:20 +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 p0D5SJUd005576 for ; Thu, 13 Jan 2011 06:28:19 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Thu, 13 Jan 2011 06:28:19 +0100 From: Polytropon To: FreeBSD Questions Message-Id: <20110113062819.4ecb89d9.freebsd@edvax.de> 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 Subject: 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: Thu, 13 Jan 2011 05:28:22 -0000 I'm aware that this is not an awk question list, but I'm confident there are many awk gurus here who can surely help me with such a stupid problem. I also know that I get more and more stupid myself for NOT being able to solve this, even after... some nearly infinite time. :-) I have strings of the form either "" or "". I catch them with if(match(nr, "[a-z]")) ... where "nr" is the name of the string. What I need is a simple space between and , so for example "12a" would get "12 a", "6d" would get "6 d", and "58" would stay unchanged. I've tried with split(), with array manipulation and could produce 10 lines of code that didn't work as intended (it produced "1122aa", "66dd" and "5588" according to the examples above). Obviously, sub(nr, "[a-z]", " [a-z]"); is nonsense. Can anybody please tell me the obvious and easy way which I am missing? Thanks a lot! =^_^= The reason I'd like to do this in awk is that I've already spent enough time creating a format converter in awk that works very fine, as intended, but is missing just this little feature. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...