Using sed to remove a block of text

$ cat text 
abc
    <!-- BOF CLEAN -->
... a bunch of stuff
    <!-- EOF CLEAN -->
def
$ sed '/<!-- BOF CLEAN -->/,/<!-- EOF CLEAN -->/d' text 
abc
def

I cannot explain it any better than Sed One-Liners Explained, Part III: Selective Deletion of Certain Lines and Special Applications.


To remove all the text starting from and including <!-- BOF CLEAN --> and ending at and including <!-- EOF CLEAN -->, use following sed command:

sed -i '/<!-- BOF CLEAN -->/,/<!-- EOF CLEAN -->/d' file_name;

Reference: Delete text or paragraph between two sections using sed

Tags:

Linux

Unix

Sed