Grep using line command
Hello
I have a pretty big problem here. I have a very large file having lines running into millions. A small sample of the data is shown below
<CRMSUB:MSIN=5000000013,BSNBC=TELEPHON-55108663-TS11&TS21&TS22,MSCAT=ORDINSUB,SUBRES=ALLPLMN-AIRSIMLA,BAOC=OIC,NUMTYP=MULTI;
<ENTRGCSERV:MSIN=5000000013,GCSERV=CALLWAIT-PROV&CALLHOLD&CLIP,CLIPOVR=NO;
<ENTRCBSERV:MSIN=5000000013,CBSERV=CBOIC,BSVG=TELEPHON,CCB=OPR,PW=0000;
<ENTRCFSERV:MSIN=5000000013,CFSERV=CFBUSY,NCS=NO,NFS=NO;
<ENTRCFSERV:MSIN=5000000013,CFSERV=CFNREPLY,NCS=NO,NFS=NO;
<ENTRCFSERV:MSIN=5000000013,CFSERV=CFNREACH,NCS=NO;
<ENTRCFSERV:MSIN=5000000013,CFSERV=CFU,NCS=NO;
<CRMSUB:MSIN=5000000017,BSNBC=TELEPHON-55103911-TS11&TS21&TS22,MSCAT=ORDINSUB,SUBRES=ALLPLMN-AIRSIMLA,BAOC=OIC,NUMTYP=MULTI;
<ENTRGCSERV:MSIN=5000000017,GCSERV=CALLWAIT-ACT-TELEPHON&CALLHOLD&CLIP&NATSS05,CLIPOVR=NO;
<ENTRCBSERV:MSIN=5000000017,CBSERV=CBOIC,BSVG=TELEPHON,CCB=OPR,PW=0000;
<ENTRCFSERV:MSIN=5000000017,CFSERV=CFBUSY,NCS=NO,NFS=NO;
<ENTRCFSERV:MSIN=5000000017,CFSERV=CFNREPLY,NCS=NO,NFS=NO;
<ENTRCFSERV:MSIN=5000000017,CFSERV=CFNREACH,NCS=NO;
<ENTRCFSERV:MSIN=5000000017,CFSERV=CFU,NCS=NO;
<CRMSUB:MSIN=5000000019,BSNBC=TELEPHON-55169401-TS11&TS21&TS22,MSCAT=ORDINSUB,SUBRES=ALLPLMN-AIRSIMLA,BAOC=OIC,NUMTYP=MULTI;
<ENTRCFSERV:MSIN=5000000019,CFSERV=CFBUSY,NCS=NO,NFS=NO;
<ENTRCFSERV:MSIN=5000000019,CFSERV=CFNREPLY,NCS=NO,NFS=NO;
<ENTRCFSERV:MSIN=5000000019,CFSERV=CFNREACH,NCS=NO;
<ENTRCFSERV:MSIN=5000000019,CFSERV=CFU,NCS=NO;
<ENTRGCSERV:MSIN=5000000019,GCSERV=CALLWAIT-PROV&CALLHOLD&CLIP,CLIPOVR=NO;
As can be seen there is only common parameter ie the MSIN. Now i have to obtain data for close to a 1000 different MSINs. I cannot grep for those MSINs from my entire data. If the first occurence for a particular MSIN is say on line 4000 of 1000000 lines. If i know that the MSIN will occur from lines 4000 to 4020 and guaranteed that the MSIN will not occur after line 4020, then is there a way that my grep command will exit after line 4020 and start looking for the next MSIN?
Will be very grateful if anyone can suggest a quick and easy solution for this.
Thanks in advance
Regards
Pradeep