假设我在文件中有波纹管内容 FILE1.TXT:
some text ...
...
begin
if somthing is true
some text here
...
fi
end
some text
我想在包括开头结尾的开始结束之间替换文本
另一个文件
file2.txt:
while read line:
do
some code
done
替换后,file1.txt应该是这样的 FILE1.TXT:
some text ...
...
while read line:
do
some code
done
some text
答案 0 :(得分:0)
关注awk
可能对您有帮助。
awk '/begin/{print;system("cat FIlE2.txt");next} 1' FIlE1.txt
输出如下。
some text ...
...
begin
while read line:
do
some code
done
if somthing is true
some text here
...
fi
end
答案 1 :(得分:0)
你可以试试这个sed
sed -e '/begin/,/end/!b' -e '/end/!d;r file2.txt' -e 'd' file1.txt