I\'m having a bit trouble of splitting a large text file into multiple smaller ones. Syntax of my text file is the following:
You could use the csplit command:
csplit \
--quiet \
--prefix=whatever \
--suffix-format=%02d.txt \
--suppress-matched \
infile.txt /^$/ {*}
POSIX csplit only uses short options and doesn't know --suffix and --suppress-matched, so this requires GNU csplit.
This is what the options do:
--quiet – suppress output of file sizes--prefix=whatever – use whatever instead fo the default xx filename prefix--suffix-format=%02d.txt – append .txt to the default two digit suffix--suppress-matched – don't include the lines matching the pattern on which the input is split/^$/ {*} – split on pattern "empty line" (/^$/) as often as possible ({*})