Grep lines before or after without grepThis entry was posted in AIX Oracle on 17.04.2012 by Miguel 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