Comparing column of variable length anf fixed width file

Hi, I have two input files.

File1:

ID Name Place
1-234~name1~Newyork
1-34~name2~Boston
1-2345~name3~Hungary

File1 is a variable length file where each column is seperated by delimitter "~".

File2:

ID Country
1-34<<11 SPACES>>USA<<7 spaces>>
1-234<<10 SPACES>>UK<<8 spaces>>

File2 is a fixed length file where Id is of 15 characters length and Country is of 10 characters length.

I need an output file such that based on ID file1 and file2 should be compared and Place column in file1 should be replaced by country column.

Output File:

ID Name Country
1-234~name1~UK
1-34~name2~USA

Thanks in advance.

awk 'NR==FNR{a[$1]=$2;next}a[$1]{print $1, $2, a[$1]}' File2 File1

Regards

Thanks for the reply. I have tried this but when Iam trying to use awk its not working .... but nawk works instead. Is there any alternative thing where I can write a shell scripting to replace Place column of variable length file with Country column of fixed length file. Thanks in advance.

To print the 3th field in a fixed column of 20 characters you can use printf instead of print:

printf("%s % s%20s\n", $1, $2, a[$1)

Regards

Thanks franklin for that reply. But I heard that we can do a validation on the delimiter "~" and can divide the record using SUBSTR command and can replace the column by another column of another file . Is it possible ? Thanks in advance.

I have tried using awk and nawk but I could not able to get it. Please let me know how to get out of this issue...