> If you instead want "^" to be considered as special in "^x ", this:
>
> --8<---------------cut here---------------start------------->8---
> sed -n 's/^x .*\(.\)$/\1/gp' "file.txt"
> --8<---------------cut here---------------end--------------->8---
Your suggestion does not add to the lines. It deletes them entirely.
<code>
cal@leela:~$ sed 's/^x .*\(.\)$/CHARIZARD/gp' "file.txt"
c ^x a1
y b2
z c3
b x d4
y e5
z f6
CHARIZARD
CHARIZARD
a ^x
y
z
e ^x
x
d qwerty ^x azerty aBc
</code>
Also, it matches incorrectly.
* An extra CHARIZARD line was inserted
* "x " at the beginning of the penultimate line was NOT matched
My intended result is to ADD text to the end of any lines that start
with "x ".
<code>
c ^x a1
y b2
z c3
b x d4
y e5
z f6
x abC W-CHARIZARD
a ^x
y
z
e ^x
x CHARIZARD
d qwerty ^x azerty aBc
</code>