awk question

Hi All,
I have the file in following format which is sorted on column1 and column 26.I need to pick up the first two rows for every subscriber number which is column 1.

S00001002|Rohit|||130 BOWDOIN ST APT 308||BOSTON|MA|02108|SUFFO||022|||||STD||||||||20011101|04|UNKNW|MR|E
S00001002|||||||||||||||||||H2256||||||03||MR|E
S00001002|||||||||||||||||||||||||02||MR|E
S00001002|||||||||||||||||||||||||01||MR|E
S00001006|Rohit1|||580 MERRIAM AVE.||LEOMINSTER|MA|01453|WORCE||046|||||STD|PJ3|||HMO Prime Rx Plus||||20120501|17|OTHMA|MR|E
S00001006|||||||||||||||||||H2256||||||16||MR|E
S00001006|||||||||||||||||||||||||15||MR|E
S00001006|||||||||||||||||||||||||14||MR|E
S00001006|||||||||||||||||||||||||13||MR|E
S00001006|||||||||||||||||||||||||12|NOPAY|MR|E
S00001006|||||||||||||||||||||||||11||MR|E
S00001006|||||||||||||||||||||||||10||MR|E
S00001006|||||||||||||||||||||||||09||MR|E
S00001006|||||||||||||||||||||||||08||MR|E
S00001006|||||||||||||||||||||||||07|441|MR|E
S00001006|||||||||||||||||||||||||06||MR|E
S00001006|||||||||||||||||||||||||05|462|MR|E
S00001006|||||||||||||||||||||||||04||MR|E
S00001006|||||||||||||||||||||||||03||MR|E
S00001006|||||||||||||||||||||||||02|461|MR|E
S00001006|||||||||||||||||||||||||01||MR|E
S00001008|Rohit2|||||||01876|HCFAS||010|||||STD|||||||ENG|19941001|01|DECEA|MR|E
S00001009|Rohit3||||||MA||MIDDL||064|050733||19140912||STD||19950301||||||19980101|02|DECEA|MR|E
S00001009|||||||||||||||||||H2256||||||01||MR|E

Desired output

S00001002|Rohit|||130 BOWDOIN ST APT 308||BOSTON|MA|02108|SUFFO||022|||||STD||||||||20011101|04|UNKNW|MR|E
S00001002|||||||||||||||||||H2256||||||03||MR|E
S00001006|Rohit1|||580 MERRIAM AVE.||LEOMINSTER|MA|01453|WORCE||046|||||STD|PJ3|||HMO Prime Rx Plus||||20120501|17|OTHMA|MR|E
S00001006|||||||||||||||||||H2256||||||16||MR|E
S00001008|Rohit2|||||||01876|HCFAS||010|||||STD|||||||ENG|19941001|01|DECEA|MR|E
S00001009|Rohit3||||||MA||MIDDL||064|050733||19140912||STD||19950301||||||19980101|02|DECEA|MR|E
S00001009|||||||||||||||||||H2256||||||01||MR|E

Any help is appreciated.

awk -F\| '++A[$1]<=2' file
1 Like