here is the problem, there are two files:
aaa.txt:
1 abc 2 def 3 ghi 4 jkl 5 xyz
bbb.txt
4 9 3 2 3 3 4 9 5 8 2 6 1 7
The question is how to replace first column of file bbb.txt with the corresponding strings from second column of aaa.txt ? Output should look like this:
bbb.txt:
jkl 9 ghi 2 ghi 3 jkl 9 xyz 8 def 6 abc 7
What I come up with already is very slow multiple grep use:
cat bbb.txt | awk '{print $1}' | while read k;
do res=$(grep $k aaa.txt | awk '{print $2}');
echo $res >> out
done
But it does not do the job at all and i have this suspicion that its way easier to do..
Thanks!