nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=6 a=1 s="sqlcode -1229" db2diag.logold2
where b=lines before, a=lines after and s=pattern to search for.
If using GNU grep, the -B and -A options provide for this
where b=lines before, a=lines after and s=pattern to search for.
If using GNU grep, the -B and -A options provide for this
