如何使用sed以特定行号将文件内容复制到另一个文件

如何使用sed以特定行号将文件内容复制到另一个文件,sed,file-io,Sed,File Io,给定2个包含以下内容的文件 文件1 4 4 7 文件2 Hello World 使用sed我们如何将file2的内容插入到file1中,从特定行号(例如第二个行号)开始获取 OutFile 4 4 Hello World 7 使用sed'2r file2'file1 细分 sed命令语法是[addr]命令[options] 2:行号地址 r:从文件读取命令 file2:我们从中读取的文件 file1:是要操作的文件 照此

给定2个包含以下内容的文件

文件1

4
4
7
文件2

Hello
World
使用
sed
我们如何将
file2
的内容插入到
file1
中,从特定行号(例如第二个行号)开始获取

OutFile

4
4
Hello
World
7

使用
sed'2r file2'file1


细分

sed命令语法是
[addr]命令[options]

2
:行号地址
r
:从文件读取命令
file2
:我们从中读取的文件

file1
:是要操作的文件

照此