Hello members,
I am stuck on a sed issue I can't seem to resolve. I am trying to get rid of lines before and after a regex match from the following dataset:
Code:
define host {
host_name 4000-somehost-app
alias 4000-somehost-app
address 192.168.2.30
use 4000-Host
}
define host {
host_name 4000-somehost2-app
alias 4000-somehost2-app
address 192.168.2.40
use 4000-Host
}
I have gotten this far but am stuck on how to proceed with removing additional lines in the beginning and a couple of lines forward:
Here is my attempt:
Code:
#!/bin/sh
sed -n '
/define host/,/}/ {
/4000-somehost-app/ D
p
}
'
My goal is to wipe out the "4000-somehost-app" and leave only "4000-somehost2-app". Can this be done with sed?
Any pointers on what I am doing wrong can be of great help.
Thanks