I have a duplicated block of text I need to delete in a large xml file. I want to keep the first block and delete the second all within the same xml tag. For example:
<!--#if-->
-- several lines of text
<!--#else-->
-- several lines of the same text
<!--#endif-->
I'd like to delete the second block between the else and endif, and keep the keep the block between the if and else tags. Any help much appreciated - the script ends up deleting the entire file.
sed -i '/^<!--#else-->/ {p; :a; N; /^\<\!--\#endif--\>/!ba; s/*.\n//}; d' test.xml