我正在尝试替换 a 中的字符串file A
:
Hello Peter, how is your dad? where is mom?
Run Code Online (Sandbox Code Playgroud)
要替换的字符串在file B
:
Peter
dad
mom
Run Code Online (Sandbox Code Playgroud)
和他们相应的替代品在file C
:
John
wife
grandpa
Run Code Online (Sandbox Code Playgroud)
预期结果:
Hello John, how is your wife? where is grandpa?
Run Code Online (Sandbox Code Playgroud)
我可以编辑file A
,file B
使用 in 中相应行中的值替换 in中的值file C
吗?
到目前为止我做了什么:
cat 1.txt | sed -e "s/$(sed 's:/:\\/:g' 2.txt)/$(sed 's:/:\\/:g' 3.txt)/" > 4.txt
Run Code Online (Sandbox Code Playgroud)
如果file B
& 中只有file C
一行,它会起作用,如果有多于一行,它将不起作用。