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 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.
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) Wayne _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"