I have a file containing following numbers file1.txt
1
5
6
8
14
I have another file named rmsd.txt which contains values like the following
1 2.12
2 3.1243
3 4.156
4 3.22
5 3.882
6 8.638
7 8.838
8 7.5373
9 10.7373
10 8.3527
11 3.822
12 5.672
13 7.23
14 5.9292
I want to get the values of column 2 from rmsd.txt for the numbers present in file.txt. I want to get something like the following
1 2.12
5 3.882
6 8.638
8 7.5373
14 5.9292
I can do that by do like that grep 1 rmsd.txt
and so on but it will take a long time. I was trying a for loop something like
for a in awk '{print $1}' file.txt; do
grep $a rmsd.txt >result.txt
done
But it didn't work. Maybe it is very simple and I am thinking in a wrong direction. Any help will be highly appreciated.