How to solve the problem of overwriting an array?

Hi all,

I have a file.....

I want to print 2nd column arranged according to order of first column, present in second file.....

So, the output should be:

I am using following code:

awk 'NR==FNR{a[$1]=$2;next}{print a[$0]?a[$0]:"ABSENT\t"}' file1 file2

But, it seems that the array created is overwriting the values one by one and finally printing only the last row.
The output Iam getting is like:

Can anyone please help me in figuring out this problem ........

There are probably spaces in the second file, try this:

awk 'NR==FNR{a[$1]=$2;next}{print a[$1]?a[$1]:"ABSENT"}' file1 file2

Hi Franklin,
Thanks.....

but ur code is also giving d same results......

ABSENT
ABSENT
ABSENT
ABSENT
21

Can u Please find some other way.....

awk 'NR==FNR{a[$1]=$2;next}{print a[$1]?a[$1]:"ABSENT"}'  file1 file2
[orange@efcgnis ~/aen/temp]cat file1
aws 21 34 678960
fsd 78 56 689754
xsa 55 77 764292
klj 32 54 567873
[orange@efcgnis ~/aen/temp]
[orange@efcgnis ~/aen/temp]cat file2
xsa
fsd
klj
sdf
aws
[orange@efcgnis ~/aen/temp]
[orange@efcgnis ~/aen/temp]awk 'NR==FNR{a[$1]=$2;next}{print a[$1]?a[$1]:"ABSENT"}' file1 file2
55
78
32
ABSENT
21

--ahamed