Article 6EVT3 Shell: how to split a file with blocks as delimiters

Shell: how to split a file with blocks as delimiters

by
Linux.tar.gz
from LinuxQuestions.org on (#6EVT3)
Hi,

I have a file.txt:
Quote:
a
b
c

d
e
f

g

h

i
I would like to split the file when I met a fixed number or more of consecutive blank lines.
So with 3+ blank lines as a separator, I'd get:

file1.txt:
Quote:
a
b
c

d
e
f
file2.txt:Quote:
g
file3.txt:Quote:
h

i
I have various ideas with counters but I have an efficiency constraint there, and I lack knowledge about advanced features of sed/awk-likes.
So any help is welcome.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments