We often get stuck in a situation where we have to send a large-sized file somewhere, but the limit on the messenger is just 150 megabytes or 2 gigabytes.
In that case, we can compress the file and split it into various parts. It can also be achieved for folders. In this article, we are going to take a look at exactly that! And after archiving, we will also take a look at how can we extract them too!
Split Files into multiple blocks
Open a terminal and navigate to the directory where you have stored your file using the cd command and use the following options along with the zip command :
zip -r -s 100m Archive.zip XYZ/
Here, -r signifies recursive in case you are compressing a directory and -s signifies the splitting up of the zip file into a specific size. The split files will have the extension .z01 .z02 and so on.
As you can see, This command has split the contents of the folder XYZ into multiple parts, each of size 100 megabytes.
Extracting the archived files
First, we will combine the multiple files into a single one using the zip command, and then using the unzip command, we will extract it. Type the following command to combine the file :
zip -F Archive.zip --out Single-archive.zip
This command will produce a file named Single-archive.zip which is the combined form of all the parts of the separated zip file. Now to uncompress, use the following command :
This command will successfully extract the zip file. In some distributions, the unzip command is not installed by default, so install it if the bash says command not found.
Splitting files into various sizes comes really useful when you have to send someone a large file over mail or some messaging application such as Telegram. And terminal-based commands make the whole process really streamlined and easy.