October 19, 2020

Create Multipart Zip & Unzip Multipart

Need to transfer or send a file zip but transfer media limit the size file? Create a multipart file using split command and join the file on receiver host.

Create a file zip.

$ zip SWhite.zip S.white-TKTlqehU_ro.mp4
$ ls -lha
total 675744
[email protected]  5 faizarseptiawan 160B Oct 19 00:28 .
[email protected] 15 faizarseptiawan 480B Oct 19 00:00 ..
-rw-r--r--   1 faizarseptiawan 165M Jun 23 04:11 S.white-TKTlqehU_ro.mp4
-rw-r--r--   1 faizarseptiawan 165M Oct 19 00:28 SWhite.zip

Create a multipart file using split command.

$ # split -b maxSize filename outputPrefix
$ split -b 50m SWhite.zip SWhite-
$ ls -lha
total 1013464
[email protected]  9 faizarseptiawan 288B Oct 19 00:29 .
[email protected] 15 faizarseptiawan 480B Oct 19 00:00 ..
-rw-r--r--   1 faizarseptiawan 165M Jun 23 04:11 S.white-TKTlqehU_ro.mp4
-rw-r--r--   1 faizarseptiawan  50M Oct 19 00:29 SWhite-aa
-rw-r--r--   1 faizarseptiawan  50M Oct 19 00:29 SWhite-ab
-rw-r--r--   1 faizarseptiawan  50M Oct 19 00:29 SWhite-ac
-rw-r--r--   1 faizarseptiawan  15M Oct 19 00:29 SWhite-ad
-rw-r--r--   1 faizarseptiawan 165M Oct 19 00:28 SWhite.zip

Join the file.

$ mkdir SWhite && mv SWhite-a* SWhite && cd SWhite
$ cat SWhite-* > SWhite.zip
$ ls -lha
total 675440
drwxr-xr-x  7 faizarseptiawan 224B Oct 19 00:30 .
[email protected] 6 faizarseptiawan 192B Oct 19 00:29 ..
-rw-r--r--  1 faizarseptiawan  50M Oct 19 00:29 SWhite-aa
-rw-r--r--  1 faizarseptiawan  50M Oct 19 00:29 SWhite-ab
-rw-r--r--  1 faizarseptiawan  50M Oct 19 00:29 SWhite-ac
-rw-r--r--  1 faizarseptiawan  15M Oct 19 00:29 SWhite-ad
-rw-r--r--  1 faizarseptiawan 165M Oct 19 00:30 SWhite.zip

Make sure the files before split and after merging are still the same.

$ md5 SWhite.zip
MD5 (SWhite.zip) = 4d158057fd3714b62987e3afa2146d51
$ md5 ../SWhite.zip
MD5 (../SWhite.zip) = 4d158057fd3714b62987e3afa2146d51