Before posting this question, I try a lot but regex is beyond my abilities and I fail couple of times, and I can't find what I need searching with Google or Stack Overflow.
Here is my sample file:
Host xmpp2
HostName 172.18.0.42
User root
Port 22
Host test
HostName 172.18.201.2
User root
Port 2223
IdentityFile /Users/arash/idkey.pem
Host afra
HostName 79.175.169.10
User root
Port 22
Host hv1
HostName 172.18.0.4
User root
Port 22
Host hv2
HostName 172.18.0.5
User root
Port 22
I want to delete for example this block
Host test
HostName 172.18.201.2
User root
Port 2223
IdentityFile /Users/arash/idkey.pem
or any other block. It's very simple if any of these text blocks is using a specific number of lines, but now it may be 4 lines or 5 lines or more so I need to remove from Host to first blank line, not a specific number of lines.