I need to use one file as an input to find and replace in another file. The following command does so, but only for the first column for each line. I need this to happen for every column.
awk -F',' 'NR==FNR{a[$1]=$2} NR>FNR{$1=a[$1];print}' OFS=',' file1 file2 > fileout
The two files look like this
file1 (the key):
0,name0
1,name1
2,name2
3,name3
4,name4
file2:
23,45,0
41,1,2,4
4,5,22,100
10,20,31,51,1
33,3
16,111,3
The output should be:
23,45,name0
41,name1,name2,name4
name4,5,22,100
10,20,31,51,name1
33,name3
16,111,name3