我有一个大文本文件,其内容设置如下:
---
title: Lorim Ipsum Dolar
---
Lorim ipsum content
---
title: Excelvier whatever
---
Lorim ipsum content goes here.
我正在尝试使用 csplit
将这个文件拆分成单独的文件。
单个文件的内容格式如下:
---
title: Lorim Ipsum Dolar
---
Lorim ipsum content
我希望能够像这样正则表达式 ---、换行符和标题 ---\ntitle
但我无法用...选择它
csplit -k products.txt '/---[^\n]title/' {99}
我尝试了很多变体都无济于事。我一直得到“不匹配”。
最佳答案
您可以使用匹配到行尾 ($
) 的正则表达式
你在想什么:
csplit -k products.txt '/^title:/' {99}
关于regex - 使用正则表达式告诉 csplit 在何处拆分文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18364411/