+4 votes
in Operating Systems by (40.5k points)
Which Linux command should I use to split a large file into smaller files such that the size of each smaller file is the same?

1 Answer

+1 vote
by (353k points)
selected by
Best answer

You can use the Linux command split with the option "-b" to split a big file into smaller files by file size. "-b" option is used to give the size of each output file in bytes. Instead of converting big size into bytes, you can also use units K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, GB,... (powers of 1000).

E.g., If the size of the big file is 10MB and you want to create five files of size 2MB, you can use the following command:

split -b 2m big_file_name

The above command will create five files: xaa, xab, xac, xad, and xae.

You can find more details about this command by typing "man split" on the terminal.