Command to split a text file according to number of lines

You can use the split command:

split -l N /path-to-file

Where N is the maximum number of lines that could be in a file.

This command will split the file into smaller files each with N number of lines.

Use man split for more info.


If you use split and create multiple files your next problem is going to be how to use Calc to manipulate all that data across all those files. And that is piling one problem onto another. With 65000 lines this will be 62(!) pages.

You are just using the wrong tool. Use Libreoffice Base or MySQL to import the data and then use Libreoffice Calc to do the calculation and/or manipulation on that data.

Regarding the limits this depends on the Libreofficeversion you are using:

  • pre 3.3.3: limit is 65 536 rows
  • 3.3.3 and later: 1 048 576 rows (1M)

If you want you can do 4m records with 3.3.3+ with 4 pages but the Base module of LibreOffice can import with almost no row limit at all if that is not enough. Here is an intro in how to do this and here is an example database with import file. Manipulating the data in Base is easy and quick.

Tags:

Command Line