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

Put all 1000 strings to find in a file called targets. Then do:
grep -Ff targets /big/data/file
That's about the best you can do quickly. It will be just one pass through the big file. I'm not sure if grep can handle 1000 strings, this could be the only problem. Use the -F as I show, it is faster since no regular expressions are involved. Do a practice run with small files to be sure you have the syntax right.

tried what you suggested but it did not work. It gave me the following error message.

grep: illegal option -- F
Usage: grep -hblcnsviw pattern file . . .

Pls suggest if i might be doing something wrong.

Regards

egrep -f targets /big/data/file

where targets is the file that contains all patterns line by line