How to Split a File into Multiple Parts in Linux

By | August 4, 2017

What’s better?

Uploading five 500MB files or a single 2.5GB file to Google Drive.

I like handling smaller files because of the horrendous upload speed that my ISP provides. So, instead of handling a single 2.5GB file, I prefer to work with a smaller chunk of data.

split-file-multiple-parts-linux

Perhaps, things are similar for you too. Whatever the case may be, if you are a Linux user, things can get better for you from now on.

You can use a Linux’s utility called split to divide a blob into multiple chunks.

Split a File into Multiple Parts in Linux

Suppose your file name is aLargeFile.mp4. You want to split it into 2 equal sized parts. Use the following command to do that:

split -b N aLargeFile.mp4

If the file you want to split isn’t in a particular directory, you can type the full qualified PATH for it.

split -b /file/location/aLargeFile.mp4

To set a particular size for the parts, you can give the –bytes option as follows:

split -b --bytes=500M /file/location/aLargeFile.mp4

Use K for Kilobyte, M for Megabyte and G for Gigabyte.

To give a prefix to all the parts of the file, you can add the word after the command. This will result in files with name partaLargeFile.mp4

split -b --bytes=500M /file/location/aLargeFile.mp4 part

Merge the File After Splitting

Of course, the splitted files are useless without merging. Use cat for merging them.

cat *aLargeFile* > aLargeFile.mp4

That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *