How can I use sed
to match the search 'pattern' and reuse it again in the 'substitution' part?
Example: I want the command:
echo "12a34" | sed 's/a/#bcd/g'
to return
12abcd34
What should be the #
parameter to get the right substitution?
s/pattern/substitusion/
you can recall by&
symbol. Thats meansed 's/a/&bcd/g'
. If you'l need just part of pattern you can use back refference:sed 's/\(a\)3/\1bcd/g'