Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Merging Columns

$
0
0
Hi,

Can you please help me.

I have 2 files to merge

File1
Code:

1251 743
1250 742
1249 741
1248 749
1247 722
1246 740
1245 739
1244 740
1243 705
1242 631
1241 590

File2
Code:

1250 247
1249 241
1248 244
1247 300
1245 276
1244 292
1243 272
1242 236
1241 263

I have try
Code:

awk NR==FNR{a[$1]=$2;next}$1 in a{print $0,a[$1]} file1 file2
I get this
Code:

1250 247 742
1249 241 741
1248 244 749
1247 300 722
1245 276 739
1244 292 740
1243 272 705
1242 236 631
1241 263 590

But I will like something like this.
Code:

1251 743   
1250 742 247
1249 741 241
1248 749 244
1247 722 300
1246 740   
1245 739 276
1244 740 292
1243 705 272
1242 631 236
1241 590 263

How I can get my desired output..

Thanks :b:

Viewing all articles
Browse latest Browse all 16232

Trending Articles