Categories: Text Tools

Split command on Linux (split files) [Basic Guide]

The split command in Linux (split) is used to split large files into smaller n-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 names of the output files follow the standard file aa files ab file ac, 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 divide the input file;
  • -b bytes: Divide the file into a defined number of bytes.

In this example, the grocery list file is divided into 4 files with the suffix “list” with two lines each:

$ split -2 supermarket list 
$ ls -l
-rw-rw-r-- 1 ec2-user ec2-user 14 Sep 13 09:08 listaaa
-rw-rw-r-- 1 ec2-user ec2-user ec2-user 13 Sep 13 09:08 listaab
-rw-rw-r-- 1 ec2-user ec2-user 14 Sep 13 09:08 listaac
-rw-rw-r -- 1 ec2-user ec2-user Sep 12 13 09:08 listaad

-rw-rw-r– 1 ec2-user ec2-user ec2-user 53 Sep 13 08:40 supermarket

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Share
Published by
Uirá Endy Ribeiro

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.