pattern matching with comma delimited text

Hi,

I have two files that I need to match patterns with and the second file has comma delimited rows of data that match but I'm having trouble getting a script to work that gives me the match output to these sets :

file 1:

PADG_05255
PADG_06803
PADG_07148
PADG_02849
PADG_02886
PADG_05295
PADG_01010
PADG_01141
PADG_02836
PADG_04289
PADG_08126
PADG_05265
PADG_00557
PADG_05676
PADG_03527
PADG_00102
PADG_07457
PADG_03012
PADG_05018
PADG_04985
PADG_07697

file 2:

PADG_04295
PADG_04294
PADG_04293
PADG_01010,PADG_04292
PADG_04291
PADG_04289
PADG_04288
PADG_04287,PADG_02886,PADG_07699
PADG_04286
PADG_04285
PADG_04284
PADG_04283
PADG_04281
PADG_03285
PADG_04280
PADG_04279
PADG_04278

Desired output:

PADG_01010,PADG_04292
PADG_04287,PADG_02886,PADG_07699
PADG_04289

there're multiple threads on a similar subject - pls use the 'Search' function to find a 'hint' (not THE solution).

nawk -F',' 'NR==FNR {a[$0]; next} $1 in a' file1 file2
grep -f file1  file2 > results

Thanks for your help!

I don't have nawk- but, using awk I got the following output:
PADG_04289

Any suggestions on how to get the output:
PADG_01010,PADG_04292
PADG_04287,PADG_02886,PADG_07699
PADG_04289

(the comma delimited text is really giving me the problem)
Thanks again,
M

given your sample input files, I get this:

PADG_01010,PADG_04292
PADG_04289

'PADG_04287' ( in file2's 'PADG_04287,PADG_02886,PADG_07699') is NOT in file1. Where does it come from?

PADG_04287,PADG_02886,PADG_07699 should be in the output because PADG_02886 is
in files 1 and 2.

nawk -F',' 'NR==FNR {a[$0]; next} {for(i=1;i<=NF;i++) if ($i in a) {print;break}}' file1 file2

Thanks again for your help!

I don't have nawk- but, using awk I still get the following output:
PADG_04289

Any suggestions on how to get the output: (Maybe someone who knows Perl?)
PADG_01010,PADG_04292
PADG_04287,PADG_02886,PADG_07699
PADG_04289

(the comma delimited text is really giving me the problem)
Thanks again,
M

sorry to hear - I'm getting the correct output under Sun/Solaris.