I have the following file:
line1
line2
MATCH
line3
line4
I need to find the pattern, "MATCH" and delete the line before and after MATCH. So the result should be
line1
MATCH
lline4
I have to use sed because it is the only utility that is common across my environments. I found the following sed command but it does not print the last line of the file.
sed -i.bak -n -e'1h' -e'1!H' -e '/MATCH/{p;n;n;h;d}' -e 1b -e 'x;P' filename