Mapping and replacing numbers in two files

hi i have two files
one of the form

1    2
2    45    
3    56
4    98    
5    6598
6    98
7    10
8    0
9    15
10    56

This file's significance is that it maps the number in first column to that of the number in second column

The other file is of the form

1
2
1
3
4
5
6
3
3
6
6

now i want to replace each number in the second file according to the mappings in the first file

e.g for above files the file 2 should become like

2
45
2
56
98
6598
98
56
56
98
98

i know sed command but how can i apply it to two files so that it will happen in single line command ?

Thanks in advance

using (n)awk:

#  nawk 'NR==FNR{x[$1]=$2;next}{print x[$1]}'  map infile
2
45
2
56
98
6598
98
56
56
98
98

HTH

2 Likes