How to segment files using the split command

How to segment files using the split command

Have you ever been tasked with splitting a gigantic spreadsheet or CSV into smaller segments? When using an application like Excel, this can be a huge pain in the butt.

Thankfully, using a simple command from the terminal, you can split these huge files into segments in literal seconds! Let’s get started!

Let’s pretend you have a CSV file that contains 60k rows, each consisting of 8 columns. Sure, you could open the file, select a couple of thousand rows at a time, copy into a new spreadsheet and save that new file. Although this will do the trick, Linux (or any Unix based OS) offers an even better solution.

In order to split a large file into smaller files, use the split command:

split [options] yourfile segmentnames 
You can split a file by line number: -l linenumber, or bytes: -b bytes. In my case, I’m typically working with spreadsheets:

split -l 2000 myfile segment

The command above will split the existing file into segments of 2000. If the original file consists of 60k lines, the resulting output will create 30 files consisting of 2000 lines.



Once you’ve split your files, you’ll find that each file contains no extension. You can quickly and easily rename each file, adding the appropriate extension type. In my example, I’ll use .csv. Once your segments have been created, select all of the newly created files > right click > rename (or F2). Hit Enter or click the “Rename” button and PRESTO! All of your new segments have been renamed with the appropriate file extension:


This is a relatively simple example of a rename template. Much more can be accomplished if you need a more specific naming schema. I recommend playing around with additional options by clicking “+Add” on the right side of the input field.

I use the split command at least once a week. It has saved countless hours of screwing around, manually splitting files up. The beauty here: Even if your file doesn’t open due to its size, the entire process of splitting can be done without cracking the file open.

Divi WordPress Theme
An introduction

An introduction

Fourteen billion years ago, an object no larger than the size of an atom sat floating in the great unknown, until BOOM! One trillionth of a second later, that same atom-sized object expanded to over 180 million miles in diameter. It’s hard to imagine that the entire contents of the known universe used to fit into something so small, we’re still incapable of viewing a clear picture of it, even with our most powerful electron microscopes.

Welcome to the beginning of my blog, Rabid Sample. My name is Chad Youngblut. I am the Chief Technology Officer at First Union Lending – A private alternative lender located in Orlando Florida. I’m also the Chief Executive Web Slinger at RS Web Services – My side hustle and “hobby job.”

I enjoy providing solutions to fellow web designers, developers and like-minded folks interested in development and design. My goal is to use as a place to share tips, tricks, and techniques that I use in my projects. I also plan to share some of the tools I use, and how to get the most out of them. I may also “grace” you with ramblings about the known universe.

There have been many occasions where I’ve spent countless hours searching for solutions to specific problems, and so if I can provide something of use to even one fellow web-slinger – saving them hours of research – I consider that a success.