在包含 '>' 的行分割文件特点
我有一个文件,其中一些行以“>”开头以及以某些字母开头的所有其他行。我想将我的大文件切成几个较小的文件,以便剪切始终紧接在带有“>”的行之前。
我记得曾经我可以自己在 bash 中编写类似的东西,但不幸的是我没有保存副本。
例如
>1
HAVE
ANIC
EDAY
>2
FOLK
SE
>3
SUNS
HINE
将生成 3 个文件,每个文件都有 '>'在第一行。
I have a file with some lines starting with '>' and all other lines starting with some letters. I would like to cut my big file into several smaller so that the cut would always be immediately before line with '>'.
I remember once I could write something like that in bash on my own, but unfortunately I did not save the copy.
for example
>1
HAVE
ANIC
EDAY
>2
FOLK
SE
>3
SUNS
HINE
will result into 3 files, each having '>' at the first line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个,看看它是否有帮助
生成的文件名将是1.txt,2.txt.....
如果您需要特殊的名称模式,则需要更改awk行(>之后)。
try this, see if it helps
the generated filenames would be 1.txt, 2.txt.....
if you need the special name pattern, the awk line (after >) need to be changed.