using AWK see the upper lines and lower lines of the strings??

Hi experts,

You cool guys already given me the awk script below-

awk '/9366109380/,printed==5 { ++printed; print; }' 2008-09-14.0.log

Morever, i have one more things-

when i awk 9366109380, i can also see the Upper 3 lines as well as below 5 lines of that string.

Line 1. <user>ability</user>
Line 2. <instance></instance>
Line 3. <context>sog.Administrator</context>
Line 4. <fullOperation>MAKE:NUMBER:9366109380:PPAY2;</fullOperation>
Line 5. <starttime>20081003000047</starttime>
Line 6. <stoptime>20081003000047</stoptime>
Line 7. <fullResult>940120105;;</fullResult>
Line 8. <status>FAILED</status>

//Purple

You can use grep if your grep version supports the -A and the -B option otherwise:

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

Regards

Guys Getting Error!!

bash-2.05$ awk '/9366109380/ { print a[NR%3] "\n" a[(NR+1)%3] "\n" a[(NR+2)%3] print;getline;print;getline;print;getline;print;getline;print;exit } {a[NR%3]=$0}' 2008.log

awk: syntax error near line 1
awk: illegal statement near line 1

Use nawk or /usr/xpg4/bin/awk on Solaris.

Regards