Split a file

suggest change

Running the split command without any options will split a file into 1 or more separate files containing up to 1000 lines each.

split file

This will create files named xaa, xab, xac, etc, each containing up to 1000 lines. As you can see, all of them are prefixed with the letter x by default. If the initial file was less than 1000 lines, only one such file would be created.

To change the prefix, add your desired prefix to the end of the command line

split file customprefix

Now files named customprefixaa, customprefixab, customprefixac etc. will be created

To specify the number of lines to output per file, use the -l option. The following will split a file into a maximum of 5000 lines

split -l5000 file

OR

split --lines=5000 file

Alternatively, you can specify a maximum number of bytes instead of lines. This is done by using the -b or --bytes options. For example, to allow a maximum of 1MB

split --bytes=1MB file

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents