EN
Bash - split file into parts (by size)
8
points
In this short article, we would like to show how to split file into parts in Bash.
Quick solution:
split -b 10MB big_file.ext part_file.ext.
Where:
-b 10MB
means max size of single part,big_file.ext
means path to input file that we want to split,part_file.ext.
means prefix-path of output files
(where command generates files as:part.ext.aa
,part.ext.ab
,part.ext.ac
, ...).
Practical example
Let's suppose we have database backup as file that we want to split into multiple 10MB parts.
Example command:
split -b 10MB backup/batabase.sql backup/part.sql.
Example result:
Splitting input stream
Example command:
cat /path/to/somewhere.ext | split -b 10MB - /path/to/part.sql.
Where -
means stdin usage with split
command.