Artificial intelligent assistant

sed: match pattern, and replace every occurence of a different pattern thereafter Suppose I have `aaaaabaaaaa`, and assume that `a` can be an arbitrary pattern; likewise for `b`. How do I pattern match for `aaaaaab`, then replace all the `aaaaa`'s after `b` with `b`'s, but none of the `a`'s prior to `b`?

Too complex in sed, but much easier in Perl:


perl -pe '/b/g and substr($_, pos) =~ s/a/A/g'


The first match `/b/g` matches the first `b` in the string which sets `pos` to its position. Then, the substring starting at that position undergoes the substitution.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1f0c2c68f22fafa21b70cb66a96eb767