Existe um comando split
:
~$ split --help
Usage: split [OPTION]... [INPUT [PREFIX]]
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default
size is 1000 lines, and default PREFIX is 'x'. With no INPUT, or when INPUT
is -, read standard input.
...
-n, --number=CHUNKS generate CHUNKS output files.
...
CHUNKS may be:
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
l/K/N output Kth of N to stdout without splitting lines
r/N like 'l' but use round robin distribution
r/K/N likewise but only output Kth of N to stdout
Então você só precisa fazer
~$ split -n10 -d myfile mySubFile_
Isso cria 10 arquivos com sufixos numéricos ( -d
option) com sufixo mySubFile_
~$ ls -1t
mySubFile_00
mySubFile_01
mySubFile_02
mySubFile_03
mySubFile_04
mySubFile_05
mySubFile_06
mySubFile_07
mySubFile_08
mySubFile_09
que você pode recombinar com
cat mySubFile_* > myfile