且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在文件中使用sed替换行与另一个文件

更新时间:2023-01-07 15:36:57

来自@Aaron

sed "s/^.*find.*$/$(cat newline.txt)/" infile.txt

find 是infile.txt中的唯一字符串,该字符串返回单行,然后将该行替换为newline.txt

Where find is a unique string in infile.txt that returns a single line, the line is then replaced by newline.txt