merging of files.

Hi,

I want to merge the two files on the basis of columns like...

file 1

Data Key
A 12
B 13

file2
Data Value
A A1
A A2
B B1
B B2

output:

Data Key Value
A 12 A1
A 12 A2
B 13 B1
B 13 B2

there are some more columns in file 1. I want those columns as they are in my result file.

In short, I want each different row for each "value" in the file2.

is it possible?

Thanks.

go look at the box at the top of this thread "More UNIX and Linux Forum Topics You Might Find Helpful" and see if you can find what you want

Hi,

I searched but unfortunately I couldn't find anything similar to my requirement.

I want something reverse of this

in this thread, files are getting merge with unique.( no duplicates)

but I want the duplicates of other fields.
file1

file2

output:

Please suggest.

I did n't check it throughly . Pls test it.

 
awk 'NR==FNR {a[$1]=$2;next} a[$1] { print $1","a[$1]","$2}' Afile  Bfile

Hi panyam,

It is working.

Thanks a lot.

can someone please modify the above solution to deal with more columns in the first file..

I tried but not getting it.
I dont have very much exposure to awk. thats is really unfortunate sometimes: (