grep option to print the first match of each member of a list?

Hello,
How to grep only the first match of each (unique) member of a list from the file?
Say member.list contains:

member1
member2
member3

and table.tab which is sorted by the first 2nd and then 3rd column.

member1 1.2 234
member1 1.1 234
member2 3.3 111
member2 2.3 222
member2 2.3 111
member3 1.0 123
member3 1.0 134

and output is:

member1 1.2 234
member2 3.3 111
member3 1.0 123

Option -m or -c seems not what I need. Thanks a lot!

Yifang

grep has no recall, and can't do logical statements.

how about awk, which has variables for recall and can do logical statements:

awk 'BEGIN { while(getline<"datafile") M[$1]=1 }; { if(M[$1]==1) { print; M[$1]=2 } }' listfile

I thought there might be a option for grep. Of course this awk work great except the print---I need the whole row of the first match, which can be fixed I think.
Thank you very much.

In what way doesn't it work? 'print' ought to print the entire row.

Try this...

while read line; do grep -m 1 $line table.tab; done < member.lists

btw, Corona's awk solution works for me...

--ahamed

Sorry!
After your last email I double checked the script and found out the mistake I made was the swapped order of the two files, which should be:

awk 'BEGIN { while(getline<"listfile") M[$1]=1 }; { if(M[$1]==1) { print; M[$1]=2 } }' datafile

Thanks a lot!
Yifang