[英]Split a text file into multiple files based on filename given on each line
[英]split file by line. filename determined by first word
我有一行大文本文件:
Gen.1.1 in the beginning...
Gen.1.2 and earth was...
Rev.22.20 he talks...
我想按行拆分文件,其中文件名应为第一个字符串。
gen.1.1.txt应包含:
Gen.1.1 in the beginning...
gen.1.2.txt应包含:
Gen.1.2 and earth was...
rev.22.20.txt应该包含:
Rev.22.20 he talks...
我已经尝试了基本拆分(当然,文件名并不理想):
awk '{print > substr($0, 0, 1)}' file
尝试使用:
awk '{ print >> $1".txt" }' myfile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.