i want to split file by regular expression, i have file format as below

0|t| lorem ...
some text 
138|t| title 
some text 

if i execute egrep "[0-9]+\|t\|" file | wc -l it counts occurrence correctly but if i execute csplit filename /[0-9]+\|t\|/ then it says no match found and does not split file.

seems some issue with pipe in pattern but not able to figure out solution.

  • Put it in quotes. csplit filename '/[0-9]+\|t\|/'
    – Wildcard
    Mar 30, 2017 at 6:01

1 Answer 1


You must realize that csplit regexes are Basic Regular Expressions (BRE) and hence would not understand the + \| etc.

Just do this:

csplit yourfile '%^[0-9]*|t|%' '/^[0-9]*|t|/' '{*}'

Then look for files named xxNN in your current directory.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .