Hi,
There probably several ways to tackle this. Probably? Yes, I don't know if there are any empty lines between the VirtualHost entries. I assume (dangerous, I know) that there are.
If so, here are 2 (one useful, one for fun):
Using awk:
awk 'BEGIN { FS="\n" ; RS="" } $3 !~ /ServerName www.something.com/ { print $0, "\n" }' infile
Don't know the level of experience you have with awk, so here's a nutshell explanation.
BEGIN { FS="\n" ; RS="" } => This sets the Field (FS) and Record (RS) separator. Normally awk reads entries one line at the time, from left to right (RS="\n" and FS=" "), this makes sure that a one paragraph (empty line being the record separator) is read.
$3 !~ /ServerName www.something.com/ { print $0, "\n" } => If field 3 does not match 'ServerName www.something.com', print the paragraph.
If something isn't clear: Just ask.
And if you really, really want to do this with sed:
Code:
#!/bin/bash
sed -n '
# if an empty line, check the paragraph
/^$/ b para
# else add it to the hold buffer
H
# at end of file, check paragraph
$ b para
# now branch to end of script
b
# this is where a paragraph is checked for the pattern
: para
# return the entire paragraph
# into the pattern space
x
# look for the pattern, if there - delete, print all other paragraphs
/ServerName www.something.com/{d}
p
' $1
Hope this gets you going again.