Deleting Multiple Lines with sed

I am trying to use sed to delete multiple lines in a file. The problem is that I need to search for a certain line and then once found delete it plus the next 4 lines. For instance if I had a file that consisted of the following lines:

#Data1.start
(
(Database= data1)
(Name = IPC)
(Description = )
)
#Data2.start
(
(Database= data2)
(Name = IPC)
(Description = )
)
#Data3.start
(
(Database= data3)
(Name = IPC)
(Description = )
)

I need to be able to sed the file and delete the line starting with #Data2.start plus the next four lines.

Can anyone please give me the correct syntax to do this?:confused:

sed '/#Data2.start/{N;N;N;N;d;}'

1 Like