split—splits a file into pieces

split [ –n ] [ filename [ name ] ]

split reads filename and writes it in n line pieces into a set of output files. The first output file is named with aa appended, and so on lexicographically, up to zz (a maximum of 676 files). The maximum length of name is 2 characters less than the maximum filename length allowed by the filesystem. See statvfs(2). If no output name is given, x is used as the default (output files will be called xaa, xab, and so forth).

Example A.54.
1  split -500 filea
2  split -1000 fileb out


  1. Splits filea into 500 line files. Files are named xaa, xab, xac, etc.

  2. Splits fileb into 1000 line files named out.aa, out.ab, etc.

Get Linux Shells by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.