Split files into pieces (POSIX)
split [-[l] line_count] [-a suffix_length] [file [name]] split -b n[k|m] [-a suffix_length] [file [name]]
The split utility reads an input file and writes the data from that file into one or more output files.
By default, the names of the output files are xaa, xab, ..., xzz, and each output file, except possibly the last, gets 1000 lines.
The last file will contain the remainder of the input file, and therefore may be smaller than the requested size. Conversely, it may be longer than the other files if there are too few filenames available to take all the input in chunks of the specified size.
Suppose you have a file named big_file that's 8192 lines in length. The following command will create nine files named xaa, xab, xac, ..., xai. The first eight files will all contain 1000 lines, while the last file will contain only 192.
split big_file
The following command will produce files similar to those above, except the output filenames will consist of a three-letter suffix (i.e. xaaa, xaab, xaac, and so on):
split -a 3 big_file
Again, assuming that big_file is 8192 lines in length, the following command will create only two files: smaller_aa, which will contain 8000 lines, and smaller_ab, which will contain 192 lines.
split -l 8000 big_file smaller_
You can use any file as input, but if you're splitting a non-text file, you must specify option -b. The output files contain portions of the original input file that are otherwise unchanged.
awk, cat, cut, head, sed, tail