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

How to use sed to copy file content to another at a specific line number

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

File 1

4
4
7

File 2

Hello
World

使用sed我们如何将file2的内容从特定行号(例如第二行)开始插入file1以获得

OutFile

4
4
Hello
World
7

使用sed '2r file2 ' file1


细分

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

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

读取的文件

file1: 是要手术的那个

关注这个section