I use this command to find a search (Nr of active alarms are) and print one line before and 10 lines after the search keywords.
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=1 a=10 s="Nr of active alarms are:" *.log
However, I would like to know how to tell it to print from the search pattern "Nr of active alarms are" until it find a search pattern "NUMBER"
INPUT FILE:
A
B
C
D
E....Z
Command: nawk <search B and output from line B until you find D" Basically print B and whatever line between B and D.
OUTPUT:
B
C
D
Hope that's simple to understand: