andromedarabbit
3/13/2016 - 1:13 AM

In Unix, how can I split large files into a number of smaller files?

In Unix, how can I split large files into a number of smaller files?

See In Unix, how can I split large files into a number of smaller files?

Based on lines

In this simple example, assume myfile is 3,000 lines long:

split myfile

This will output three 1000-line files: xaa, xab, and xac.

Based on the file size

Finally, assume myfile is a 160KB file:

  split -b 40k myfile segment

This will output four 40KB files: segmentaa, segmentab, segmentac, and segmentad.