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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
64 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
我想通过行前缀将它拆分成单独的文件..像这样:
file 60 contains all lines prefixed with "60"
file 61 contains all lines prefixed with "61"
...
到目前为止我提出的最好的想法是grep所有的行前缀,然后遍历它并将其中的每一个grep插入一个单独的文件,但它是一个相当大的文件,所以这可能需要很长时间。也许有比循环和grepping更好的方法? grep分组的一些方法?我知道如果每个部分之间都有标记,有一种方法可以将文件剪切掉 - 但我不完全确定这是最好的方法。
另外,如果有一些方法可以在vim中做到这一点也很好
—
slf