
次の 2 つのファイルがあります。
ファイル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