使用正则表达式来告诉csplit可哪里拆分文件 [英] Using regex to tell csplit where to split the file
本文介绍了使用正则表达式来告诉csplit可哪里拆分文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有内容的大的文本文件设置是这样的:
I have a large text file with content set up like this:
---
title: Lorim Ipsum Dolar
---
Lorim ipsum content
---
title: Excelvier whatever
---
Lorim ipsum content goes here.
我试图分裂这个文件到使用单独的文件则csplit
。
中的各个文件将不得不格式化了这样的内容:
The individual files would have content formatted like this:
---
title: Lorim Ipsum Dolar
---
Lorim ipsum content
我希望能够在正则表达式---符,换行符&安培;标题像这样 --- \\ n标题
但我不能用......选择它
But I'm not able to select it with…
csplit -k products.txt '/---[^\n]title/' {99}
我试过很多的变化无济于事的。我保持越来越不匹配。
I've tried lots of variations to no avail. I keeping getting "no match".
推荐答案
您可以使用,直到行结束( $
匹配的正前pression )
You could use a regular expression that matches until the end of the line ($
)
那你想想:
csplit -k products.txt '/^title:/' {99}
这篇关于使用正则表达式来告诉csplit可哪里拆分文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文