In Linux you can use split and join commands to split large files into smaller files or join many smaller files into a large file. This kind of operations are often necessary when you are dealing with large quantities of data.


Following is the default functionality of split. It splits a large file every thousand lines and creates new files.

$ split largefile.txt

$ ls
largefile.txt  xaa xab  xac  xad

$ wc -l *
3285  largefile.txt
1000  xaa
1000  xab
1000  xac

You can also define the number of lines you want in each file

$ split -l 2000 largefile.txt

$ ls
largefile.txt  xaa xab

$ wc -l *
3285  largefile.txt
2000  xaa
2000  xab
2000  xac

By master