I have some text like:Blablabla <b>[intlink id=</b>2204<b> type=page] BlalalaI want replace it for remove the </b> and <b>, keeping the id=number. So it should result like:Blablabla <b>[intlink id=2204 type=page] BlalalaI try with:sed -i 's@id=</b>[[:digit:]]\+<b>@id={1}@g' ~/edit.txtBlablabla <b>[intlink id={1} type=page] BlalalaAlso I try with:sed -i 's@id=</b>[[:digit:]]\+<b>@id=\\1@g' ~/edit.txtBut I get:Blablabla <b>[intlink id=\1 type=page] BlalalaSo, how I can keep the id number text in the regex digit?
Sed: replace text keeping digit occurrence
sed;regular expression;replace;html;trim
\1 is the right syntax for referring to capture group 1; \\1 means you want the literal text \1. So change \\1 to \1, and then you need to put parentheses around the part you actually want to capture. This should work:sed -i 's@id=</b>\([[:digit:]]\+\)<b>@id=\1@g' ~/edit.txt