|
From: | Luuk |
Subject: | Re: [bug-gawk] Is there a way to change a string inplace by index? |
Date: | Sun, 4 Sep 2016 12:24:19 +0200 |
On 04-09-16 05:03, david kerns wrote:
true, but put this isn't python ;)I think the closest you'll come to in-place substitution is sub() and gsub(), but those are regex (content) replacements not position based. You could do this:awk 'BEGIN { s = "0123456789"; i = 7-1; ss = substr(s,0,i); sub(ss ".", ss "x", s) ; print s }'
another variation on this:awk 'BEGIN { t="........."; s = "0123456789"; i = 7-1; s = gensub("(" substr(t,1,i) ").","\\1x",1,s); print s }'
[Prev in Thread] | Current Thread | [Next in Thread] |