Assume I have the following example text in
<para>This is some paragraph text This is another line of paragraph text. </para>
What I want to achieve: Replace all
</para> tags with the null string, if the resulting line is empty, delete the line. I achieved this with the following two commands:
# remove the line that solely consist of the para tag. $ sed -i '/^<para>$/d;/^<\/para>$/d' ./example.txt # Replace any of the para tags with an empty string. $ sed -i 's/<para>//g;s/<\/para>//g' ./example.txt
My question: Is it possible to achieve this in one sed command, making use of a conditional line deletion?