split a textfile after each n matches to a new file using sed or awk

Posted by ozz on Super User See other posts from Super User or by ozz
Published on 2013-11-09T15:08:40Z Indexed on 2013/11/09 15:59 UTC
Read the original article Hit count: 219

Filed under:
|
|

i tried to split a file in parts of n matches each. The file is just one line and the seperator is '<br>'

foo<br>bar<br>.....<br>

I just want to split the file in parts, where each file has 100 datasets (text plus <br>)( normaly 100 datasets, but at the end maybe less)

I already played around with this ... split-file-in-2-with-sed and this split-one-file-into-multiple-files-based-on-pattern

sed.exe -e "^.*.<br>{0,100}/g" < original.txt > first_half.txt

The split do not work an the result is only 1 file instead of many.

© Super User or respective owner

Related posts about shell

Related posts about sed