![열을 일치시킬 때 한 파일의 문자열을 다른 파일의 내용으로 바꿉니다.](https://linux55.com/image/143757/%EC%97%B4%EC%9D%84%20%EC%9D%BC%EC%B9%98%EC%8B%9C%ED%82%AC%20%EB%95%8C%20%ED%95%9C%20%ED%8C%8C%EC%9D%BC%EC%9D%98%20%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%84%20%EB%8B%A4%EB%A5%B8%20%ED%8C%8C%EC%9D%BC%EC%9D%98%20%EB%82%B4%EC%9A%A9%EC%9C%BC%EB%A1%9C%20%EB%B0%94%EA%BF%89%EB%8B%88%EB%8B%A4..png)
다음과 같은 두 개의 파일이 있습니다.
파일 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