How to use sed to search for string and Print previous two lines and current line

Hello,

Can anybody help me to correct my sed syntax to find the string and print previous two lines and current line and next one line.

i am using string as "testing"

netstat -v | sed -n -e '/test/{x;2!p;g;$!N;p;D;}' -e h

i am able to get the previous line current line next line but unable to print the previous to previous line not able to get.

i.e.

this line to print
this line to print
test:This line to print
this line to print.

Can anybody help me

Madhu

With awk:

awk '/test/ {
  print a[NR%2] "\n" a[(NR+1)%2]
  print;getline;print;getline;exit
}
{a[NR%2]=$0}
' file

Regards