split was my immediate thought and it
works but I'm going to assume the OP wants the integrity of each word saved.
Examining the file below you'll notice it splits on [ok] and [4]. Not good if you have a wordlist.
Code:
$ cat foobar
ok1
ok2
ok3
ok4
ok5
ok6
ok7
Code:
$ split -n2 foobar
$ cat xaa; echo -e '\n\n'; cat xab
...
ok3
ok
4
ok5
...
To make this work, examine these parts of the
-n --number=CHUNKS command
Code:
N split into N files based on size of input
K/N output Kth of N to stdout
l/N split into N files without splitting lines/records
l/K/N output Kth of N to stdout without splitting lines/records
r/N like 'l' but use round robin distribution
r/K/N likewise but only output Kth of N to stdout
There's another part, separating on another character besides the newline, however I could not get that to work
Code:
-t, --separator=SEP
use SEP instead of newline as the record separator; '\0' (zero)
specifies the NUL character
Code:
split -t '\n' foobar
split: multi-character separator ‘\\n’
I'm not sure why the above does not work, or more specifically, how to specify a newline (or tab, etc)