Linux split Command: Split Large Files into Smaller Parts
Linuxcommands
The split command in Linux (split) is used to split large files into n-smaller files. The output files are generated according to the number of lines in the input file. The default is to split the file every 1000 lines. The output file names follow the pattern fileaa fileab fileac, and so on. You can specify a suffix for the output file.
The most common option is:
- -n: Where n is the number of lines that will split the input file;
- -b bytes: Split the file into a defined number of bytes.
In this example the supermarket list file is split into 4 files with suffix "lista" with two lines each:
$ split -2 supermercado lista$ ls -l-rw-rw-r-- 1 ec2-user ec2-user 14 set 13 09:08 listaaa-rw-rw-r-- 1 ec2-user ec2-user 13 set 13 09:08 listaab-rw-rw-r-- 1 ec2-user ec2-user 14 set 13 09:08 listaac-rw-rw-r-- 1 ec2-user ec2-user 12 set 13 09:08 listaad-rw-rw-r-- 1 ec2-user ec2-user 53 set 13 08:40 supermercado
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.