I want to do two things by sed
when matching a pattern:
- Replace the pattern with a string
- Append another string after this line
Such as the original content in a text file is:
abc
123
edf
I want to replace 123
to XXX
and append YYY
after the line:
abc
XXX
YYY
edf
I tried to do this by sed '/123/{s/123/XXX;a\YYY\}'
, but it gave an error: Unmatched "{"
.
It seemed that command a
treats all characters after it as text to append. So how can I make a
know the end position of the text for append?