我在每个摘要之间都有空行的大文本文件,有1000个摘要。 我想把这个文件分成1000个文本文件。 我的文件看起来像
16503654 Three-dimensional structure of neuropeptide k bound to dodecylphosphocholine micelles. Neuropeptide K (NPK), an N-terminally extended form of neurokinin A (NKA), represents the most potent and longest lasting vasodepressor and cardiomodulatory tachykinin reported thus far. 16504520 Computer-aided analysis of the interactions of glutamine synthetase with its inhibitors. Mechanism of inhibition of glutamine synthetase (EC 6.3.1.2; GS) by phosphinothricin and its analogues was studied in some detail using molecular modeling methods.
您可以使用拆分,并将“每个输出文件的NUMBER行”设置为2.每个文件都有一个文本行和一个空行。
split -l 2 file
你总是可以使用csplit命令。 这是一个文件分割器,但基于正则表达式。
一些沿线的东西:
csplit -ks -f /tmp/files INPUTFILENAMEGOESHERE '/^$/'
这是未经测试,可能需要一点点调整。
CSPLIT
像这样的东西:
awk 'NF{print > $1;close($1);}' file
这将创建1000个文件名为抽象数字的文件。 这个awk代码将记录写入一个名字从第一个字段($ 1)中检索的文件。 这只有在字段数大于0(NF)