I use Debian and I have a text file and I want to split that into several files with specific suffix name and size. I want split that file by n chunk therefore, I should use -n option. How can I do that with split command? Thanks
Asked
Active
Viewed 1,601 times
1 Answers
3
With split (GNU coreutils) you could split file
into N
chunks split00.part
, split01.part
, ... split[N-1].part
:
by size - lines can be splitted "into two halves", but all parts have the same size
split -d -nN --additional-suffix=.part file split
at whole lines/records - parts may slightly differ in size
split -d -nl/N --additional-suffix=.part file split
or split by defined size of chunks in bytes like 1MiB
split -d -b1048576 --additional-suffix=.part file split

Freddy
- 25,565
split
with specific size, and then rename all of them afterwards? For example withrename
from the Debian packagerename
(which can rename multiple files at once, according to a pattern). – dirkt May 04 '19 at 18:48