sed -n '{ /削除したい行/{ g; s/\n[^\n]*$//; h; n; n; bc }; H; s/.*//; :c }; ${ g; s/\n//; p }'

黒魔術じみたコードになっちゃった…