Another version that produces your output from your input (i.e. deleting the blank line after the
fast as well.)
sed -in 'N; s/.*fast.*$//; /./p;' filename
I'm not sure but I think this will work too:
sed -i 'N; /fast/d' filename
N; command combines two lines into one pattern space in
sed. You can then write regexes that match strings that span two lines. The
-n option tells sed not to automatically print lines that match the regex and the
/./p; command at the end prints any line that is not the empty string (i.e. whatever is left that we haven't deleted with the first regex). Don't forget if you do this that the
\n is still part of the pattern space and needs to be matched. I've used
.* in my first example for this.
The existing answers work fine if there are no blank lines in your input or output.
It turns out now that I've tested it that the first version of the first option was problematic. The updated version works. The second option (the one I wasn't sure about) worked perfectly the first time.