I have a text file like this
word_1 root_of_word_A
word_2 root_of_word_B
word_3 root_of_word_C
word_4 root_of_word_A
And other document like this
root_of_word_A root_of_word_1
root_of_word_B root_of_word_2
root_of_word_C root_of_word_3
I have to replace in the first document with the other words of the second document, like this
word_1 root_of_word_1
word_2 root_of_word_2
word_3 root_of_word_3
word_4 root_of_word_1
I thought that I could make something like this with awk. I tried this:
awk 'NR==FNR {print $1}{c[$2]++;next};c[$1]>0{print $2}' file1 file2
The problem is that I do not know how to print the first column of the file1 and the second of the file2.
Mention that the first file and the second have different number of lines and that there is only an example to make it more clear the thing I want to do (the problem is not to convert A to 1, is the whole root_of_the_word).