![如何分割文件?](https://linux22.com/image/45926/%E5%A6%82%E4%BD%95%E5%88%86%E5%89%B2%E6%96%87%E4%BB%B6%EF%BC%9F.png)
Input.txt
:
line.....1
line.....2
line.....3
.....
line.....3
line.....4
line.....5
.....
line.....4
line.....5
line.....6
.....
line.....5
line.....6
line.....7
.....
中提到的输出文件名的条件name.txt
。
name.txt
:
chapter01.txt
chapter02.txt
chapter03.txt
chapter04.txt
需要以下txt
文件的输出
chapter01.txt
:
line.....1
line.....2
line.....3
.....
chapter02.txt
:
line.....3
line.....4
line.....5
.....
chapter03.txt
:
line.....4
line.....5
line.....6
.....
chapter04.txt
:
line.....5
line.....6
line.....7
.....
答案1
awk -vRS= '{RS="\n";getline f < "name.txt";RS=""
print > f; close(f)}' < input.txt