Grepping within nested for loops

Good morning - I have publication lists from 34 different faculty members. I need to end up with the numbers of publications in common across all 34 faculty.

I need to grep person1 (last name) in list2, person1 in list3, person1 in list 4, etc., then person2 in list3, person 2 in list4, etc., then person3 in list4, etc.

I think (!) I need a nested for loop which I've never done before (my loops have always been along the lines of "foreach chr (1 2 3 4 5) do the following program"). VERY basic! I know a good bit of basic Unix and AWK, along with some Perl.

Any pointers will be much appreciated. Thanks, Peggy

If it is no problem to seek every list for the names instead of skipping some, you could write the names into a file "namelist" for example and then do something like:

grep -lf namelist list*

Else you can write the names into a list like above also save the lists into an array, in ksh for example

...
set -A array `ls -1 list`
...

and then work the array by incrementing it's element's index by one in a for loop when working the array against the name list, using "grep -lf namelist ${array[n]}".

Thanks very much! I haven't been able to get it to work with a list yet but will keep trying.