Input file
FS01,/root_vdm_9/UKSR06_FS01,test1
FS04,/root_vdm_11/UKSR04_FS04,test2
FS01,/root_vdm_7/UKSR02_FS01,test4
FS01,/root_vdm_12/UKSR03_FS01/dhdhdhdh,test5
FS01,/root_vdm_11/UKSR04_FS01/gggg,test6
Reference File
/root_vdm_9/UKSR06_FS01,UKSR06_FS01
/root_vdm_11/UKSR04_FS04,UKSR04_FS04
/root_vdm_11/UKSR04_FS01,UKSR04_FS01
/root_vdm_7/UKSR02_FS01,UKSR02_FS01
/root_vdm_12/UKSR03_FS01,UKSR03_FS01
/UKSR03_FS01,UKSR03_FS01
I tried this
nawk -F"," 'NR==FNR{a[$1]=$2;next}{for (i in a) gsub(i,a,$0)}1' /tmp/reference /tmp/input
Ouput I got
FS01,UKSR06_FS01,test1
FS04,UKSR04_FS04,test2
FS01,UKSR02_FS01,test4
FS01,UKSR03_FS01/dhdhdhdh,test5
FS01,/root_vdm_11/UKSR04_FS01/gggg,test6
Output I need
FS01,UKSR06_FS01,test1
FS04,UKSR04_FS04,test2
FS01,UKSR02_FS01,test4
FS01,UKSR03_FS01,test5
FS01,UKSR04_FS01,test6
Basically if a sub column or column from input file matches from $1 in the reference file , replace the complete column(not just the string ) of input file from $2 in the reference file ...
thx