[split] Split a file into chunks of N lines

Created on November 30, 2026

Use -l to set the maximum number of lines per output file. Start with this dummy.txt.

one
two
three
four
five

The following command reads the file from standard input (-), splits it into chunks of up to three lines, and names the output files with the prefix dummy.txt..

cat dummy.txt | split -l 3 - dummy.txt.

The result is dummy.txt.aa with the first three lines and dummy.txt.ab with the remaining two lines.

Shell command