Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using sed to remove a block of text

Tags:

linux

unix

sed

I have a block of text that looks like this:

    <!-- BOF CLEAN --> ... a bunch of stuff      <!-- EOF CLEAN --> 

I'd like to remove this entire block. What's the sed command?

like image 449
Scott C Wilson Avatar asked Aug 04 '11 17:08

Scott C Wilson


People also ask

Can we delete content in a file by using sed command How do you do?

There is no available to delete all contents of the file. How to delete all contents of the file using sed command.

How do you use the sed command to modify text?

Find and replace text within a file using sed command The procedure to change the text in files under Linux/Unix using sed: Use Stream EDitor (sed) as follows: sed -i 's/old-text/new-text/g' input.txt. The s is the substitute command of sed for find and replace.


1 Answers

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

http://www.catonmat.net/blog/sed-one-liners-explained-part-three/

like image 111
Maxim Egorushkin Avatar answered Sep 29 '22 11:09

Maxim Egorushkin