sed search pattern and delete lines

view story

http://www.unix.com – Hello, i have a question. My problem is that i have a file like: PHP Code: TEST JOHN ADAM MICHAEL SEBASTIAN ANDY  i want find for MICHAEL and want delete lines like this: PHP Code: TEST SEBASTIAN ANDY  delete 2 lines before pattern and one line after pattern. i have a solution but it deletes only after find pattern. PHP Code: sed '/MICHAEL/,+2d' test.txt  (HowTos)