Search posts

Linux split command

We can use split command to split one file to a number of files.
By default the ‘split’ will split the file into files that contain 1000 lines each one, and the remaining in the last file. but we can use the ‘l’ param to change the number of lines in the divided files.

so if we have file index.html that contain 16 lines and we run

split -l 4 index.html

we will get 4 files, each one contain 4 lines.

for binary file we can use the ‘-b’ option, and after the specify the binary size.

For example:

split -b 2m archive.tar

will split the file archive.tar into file with the size of 2m (last file will be the remaining size)