Introduction

If you’ve ever had the need to get some data out of a locked down environment but need to chop the data up into bits due to issues with size constriants, you have some options. There are numerous different programs out there that do this but if you’d prefer to keep it simple you can do it right in the shell.

Method

So you have a file which is big. This is the command you need to run from the terminal:

split -b <size> bigfile bigfile-part

This will create a number of smaller files depending on what size constraints you have. The <size> needs to be either 20M for 20 MB or 1G for 1 GB etc. You can find all this info in the man pages of course.

Once you have those files, just get them out through whatever method you have, (possibly email or web upload or something else)

On the receiving side you need the following command:

cat bigfile-part* > bigfile

You will end up with your original file. An extra I would advise however is to verify the files to make sure they are indeed the same. Source and destination you need the following command:

md5sum bigfile

This will give you a checksum to compare at both ends to make sure what you have is truly identical. e.g.

d41d8cd98f00b204e9800998ecf8427e bigfile

Anyone who has ever uploaded router firmware without checking this will know how important it is and how much pain it can save!

Enjoy.

Splitting and Reassembling files via the CLI Linux
Tagged on:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.