Is it possible to replace occurrences of a character sequence recursively without iterating over the same sequence again?
By performing a sed
as in the following scenarios I can get the mentioned output.
$ echo XX | sed -e 's/XX/XoX/g'
XoX
$ echo XXX | sed -e 's/XX/XoX/g'
XoXX
$ echo XXXX | sed -e 's/XX/XoX/g'
XoXXoX
However, I'm expecting the output to follow the following behavior.
Input:
XX
XXX
XXXX
Expected output:
XoX
XoXoX
XoXoXoX
Is it possible to achieve the expected behavior with sed alone?