Grep lines before or after without grep


Here a way I used in AIX, where there is a grep without the -A and -B options:

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=2 a=0 s="ORA-"  alert_us.log

Leave a comment

Your email address will not be published. Required fields are marked *