1

I want to split a file after a delimiter, not before the delimiter, which is what csplit does. I can't find anything anywhere! (Also, why would there be a tool that specifically splits before a pattern, but not one that splits after it?)

File:
a
b
c
d

split at c

output: file1:
a
b
c

file 2
d

LizzAlice
  • 113
  • 4

1 Answers1

2

The syntax is /REGEXP/[OFFSET]. So given

$ cat file
a
b
c
d

then

$ csplit file '/^c/+1'
6
2

gives

$ head xx*
==> xx00 <==
a
b
c

==> xx01 <==
d
steeldriver
  • 78,509
  • 12
  • 109
  • 152