我有两个文件,例如:
文件1:
a stringori to replace, this stringori comme again
other stringori2 to replace, stringori2 commes again
...
文件2:
stringori newstring
stringori2 newstring2
...
我想得到结果:
a newstring to replace, this newstring comme again
other newstring2 to replace, newstring2 commes again
答案1
我很确定这个问题已经在这些论坛中被解决/回答过无数次了。怎么样
awk 'NR == FNR {T[$1] = $2; next} {for (t in T) gsub (t, T[t])} 1' file2 file1
a newstring to replace, this newstring comme again
other newstring2 to replace, newstring2 commes again