awk question: replacing "%d%s" by "%d %s"
Polytropon
freebsd at edvax.de
Fri Jan 14 06:17:16 UTC 2011
On Thu, 13 Jan 2011 18:22:18 -0600 (CST), Robert Bonomi <bonomi at 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 pattern regex'.
Doesn't work on my 7-STABLE system (20080811), awk stops:
awk: syntax error at source line 78 source file konvertieren.awk
context is
sub(nr, "[a-z]", " >>> &" <<< );
awk: illegal statement at source line 79 source file konvertieren.awk
But I'll keep your suggestion in the program source and test
it on 8 as soon as my "new" home system is ready to use. At
least, the & variant looks much better.
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions
mailing list