# vi require.txt
1,BANK,Read blocks that cycle.
yellow
Read blocks.
2,ACCOUNT,Finished
Red
Finished .
3,LOAN, pipe
white
pipe
4,PROFIT,Resolve.
black
Resolve
Am using like
cat require.txt | grep -w ACCOUNT
The output I get is
2,ACCOUNT,Finished
But i need the output as
2,ACCOUNT,Finished
Red
Finished .
I need to grep the next two lines from that file once the grep patterns is matched..
# vi require.txt
1,BANK,Read blocks that cycle.
yellow
Read blocks.
2,ACCOUNT,Finished
Red
Finished .
3,LOAN, pipe
white
pipe
4,PROFIT,Resolve.
black
Resolve
5,PROFITIABLE,Loss
orange
Loss
6,ACCOUNTANT,clerk
yellow
work
If i use the code
awk '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=0 a=2 s="ACCOUNT" require.txt
The output is
2,ACCOUNT,Finished
Red
Finished .
6,ACCOUNTANT,clerk
yellow
work
This grep all pattern relative to ACCOUNT like ACCOUNT and ACCOUNTANT are grepped..
Please suggest me a way to grep the exact pattern ACCOUNT alone from this file