Re: awk question: replacing %d%s by %d %s

2011-01-13 Thread Robert Bonomi
Date: Thu, 13 Jan 2011 06:28:19 +0100 From: Polytropon free...@edvax.de Subject: awk question: replacing %d%s by %d %s 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

Re: awk question: replacing %d%s by %d %s

2011-01-13 Thread Polytropon
On Thu, 13 Jan 2011 18:22:18 -0600 (CST), Robert Bonomi bon...@mail.r-bonomi.com wrote: True. But sub(nr,[a-z], ); does the trick. (tested on Freebsd 7.2) Explamation: is a 'replacement side' magic incantation to the regex library that means 'that which was matched by the

Re: awk question: replacing %d%s by %d %s

2011-01-13 Thread Wayne Sierke
On Fri, 2011-01-14 at 07:17 +0100, Polytropon wrote: On Thu, 13 Jan 2011 18:22:18 -0600 (CST), Robert Bonomi bon...@mail.r-bonomi.com wrote: True. But sub(nr,[a-z], ); does the trick. (tested on Freebsd 7.2) Explamation: is a 'replacement side' magic incantation to the

Re: awk question: replacing %d%s by %d %s

2011-01-13 Thread Polytropon
On Fri, 14 Jan 2011 17:53:04 +1030, Wayne Sierke w...@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

awk question: replacing %d%s by %d %s

2011-01-12 Thread Polytropon
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

Re: awk question: replacing %d%s by %d %s

2011-01-12 Thread Polytropon
On Thu, 13 Jan 2011 01:00:17 -0500, Tom Limoncelli t...@whatexit.org wrote: $ awk data.txt experiment.txt '{ num = $1 ; sub(/[^0-9]+$/, , num) ; lets = $1 ; sub(/^[0-9]+/, , lets); print num lets }' ; diff -cw control.txt experiment.txt $ # The above puts a space at the end of the first 3

Re: awk question: replacing %d%s by %d %s

2011-01-12 Thread Tom Limoncelli
On Thu, Jan 13, 2011 at 12:28 AM, Polytropon free...@edvax.de wrote: I have strings of the form either number(s) or number(s)letter. I catch them with ... where nr is the name of the string. What I need is a simple space between number(s) and letter, so for example 12a would get 12 a, 6d