Help with comparing two files

Hi all

I have to compare two file this time

one is

P11223
x1124
x1145
t5678
e3456
z2345

another file

P11223           x    s
P11223           y    f
P11223         v     r
x1124              f    g
x1145             d      d
t5678               d     i
e3456           r       e
z2345             f    f

I want output shuld be

P11223         x,y,v  s,f,r  
x1124              f      g
 x1145             d       d
 t5678               d     i
 e3456             r        e
 z2345             f     f

Request to check if this solves your problem:

awk 'FNR==NR{name[$1]=1;next} $1 in name{
for(i=2;i<=NF;i++)
 data[$1,i]=data[$1,i]?data[$1,i]","$i:$i
}END{
for(i in name)
{
 printf("%s ",i)
 for(j=2;data[i,j];j++)
  printf("%s ",data[i,j])
 print ""
}
}' file1 file2
1 Like

Thank u.

I am just learning programming from this site.

ur code generated the following output

t5678 d i 
P11223 x,y,v s,f,r 
x1124 f g 
e3456 r e 
x1145 d d 
z2345 f f