Splitting files using Linux command line

/ / splitting files using linux command line

Updated: 2017-04-25

I have yet to find a text editor capable of modifying multi-GB text files on Linux, as the EmEditor only works with Windows.

So if you ever need to split a text file into smaller pieces, then you can use the following command:

split -l NUMBEROFLINES FILENAME.EXT

If you had a file named data.json and wanted to split it on every 100.000 lines, then you could run:

split -l 100000 data.json

Similarly, you can also split based on filesize rather than number of lines. If you wanted to split the data.json file on every 200MB while ensuring files are split on linebreaks, then you can run the following command:

split -C 200m data.json

That’s all there’s to it, enjoy :)