Split a file into fixed-size pieces, creates output files containing consecutive sections of INPUT
(standard input if none is given or INPUT is '-')

      split [options] [INPUT [PREFIX]]


   -l LINES
      Put LINES lines of INPUT into each output file.

   -b BYTES
      Put the first BYTES bytes of INPUT into each output file.
      Appending 'b' multiplies BYTES by 512, 'k' by 1024, and 'm' by

      Put into each output file as many complete lines of INPUT as
      possible without exceeding BYTES bytes.  For lines longer than
      BYTES bytes, put BYTES bytes into each output file until less than
      BYTES bytes of the line are left, then continue normally.  BYTES
      has the same format as for the '--bytes' option.

      Write a diagnostic to standard error just before each output file is opened.

By default, 'split' puts 1000 lines of INPUT (or whatever is left over for the last section), into each output file.

The output files' names consist of PREFIX ('x' by default) followed by a group of letters 'aa', 'ab', and so on, such that concatenating the output files in sorted order by file name produces the original input file.

If more than 676 output files are required, 'split' uses 'zaa', 'zab', etc.


Split up the file demo.zip into multiple 100 MB files:

$ split -b 100m demo.zip

The output files will be named with 3 letters starting xaa, xab, … to reassemble them, cat the files in alphabetical order:

$ cat 'ls x*' > demo2.zip

“The man who is tired of London is tired of looking for a parking space” ~ Paul Theroux

Related Linux commands

csplit - Split a file into context-determined pieces.
cut - Divide a file into several parts.
fmt - Reformat paragraph text.
fold - Wrap input lines to fit in specified width.
head - Output the first part of file(s).
join - Join lines on a common field.
paste - Merge lines of files.
Equivalent Windows commands: FC /lb - Compare two files.

Copyright © 1999-2024 SS64.com
Some rights reserved