Linux zip split archive

How to split .zip files and join them in Windows?

I need to split a .zip file in Ubuntu as .z01, .z02 etc. so that I would join them back in Windows. I don’t have access to command prompt in Windows. How would I unzip files now?

5 Answers 5

On Ubuntu you can use the split command to split your zip file. Something like this should work:

split your-zip.zip -b 32M ZIPCHUNKS 

This will create a bunch of ZIPCHUNKS* files, in order, and all 32 MB or less in size. Change the 32M parameter to vary the chunk size.

Traditionally you’d use cat to glue them back together:

cat ZIPCHUNKS* > reassembled-zip.zip 

Since you want to do the reassembling on Windows, you need a substitute for cat . Is there replacement for cat on Windows may help, but note that the Windows type command will not work as it adds the files names between them when processing more than one file. One working approach is copy /b ZIPCHUNKS* > reassembled-zip.zip .

You can also use rar which natively supports creating «split» archives which can then be decompressed by a GUI tool on Windows such as WinZip or WinRar. On Ubuntu, install the rar package, then:

rar a -v32M destination.rar files/to/compress 

This will create files called destination.partXX.rar. Transfer these to Windows, then unrar the first one (destination.rar), which will link to the others automatically.

One trick you can potentially use is to «rar» the original zip file, that way you can reassemble it on Windows. If you have the original files, it may be easier to just rar them and work with that.

Читайте также:  Linux чем ограничить скорость

Источник

Split files using tar, gz, zip, or bzip2 [closed]

I need to compress a large file of about 17-20 GB. I need to split it into several files of around 1GB per file. I searched for a solution via Google and found ways using split and cat commands. But they did not work for large files at all. Also, they won’t work in Windows; I need to extract it on a Windows machine.

Many compression programs (e.g. like 7-Zip) is able to split the compressed file into volumes of a specified size for easier distribution.

If one of the two viable solutions posted here doesn’t pan out, he’ll be needing a programming solution.

4 Answers 4

You can use the split command with the -b option:

It can be reassembled on a Windows machine using @Joshua’s answer.

copy /b file1 + file2 + file3 + file4 filetogether 

Edit: As @Charlie stated in the comment below, you might want to set a prefix explicitly because it will use x otherwise, which can be confusing.

split -b 1024m "file.tar.gz" "file.tar.gz.part-" // Creates files: file.tar.gz.part-aa, file.tar.gz.part-ab, file.tar.gz.part-ac, . 

Edit: Editing the post because question is closed and the most effective solution is very close to the content of this answer:

# create archives $ tar cz my_large_file_1 my_large_file_2 | split -b 1024MiB - myfiles_split.tgz_ # uncompress $ cat myfiles_split.tgz_* | tar xz 

This solution avoids the need to use an intermediate large file when (de)compressing. Use the tar -C option to use a different directory for the resulting files. btw if the archive consists from only a single file, tar could be avoided and only gzip used:

# create archives $ gzip -c my_large_file | split -b 1024MiB - myfile_split.gz_ # uncompress $ cat myfile_split.gz_* | gunzip -c > my_large_file 

For windows you can download ported versions of the same commands or use cygwin.

Читайте также:  Стандартный пароль от kali linux root

Источник

How to zip files with a size limit?

I have a script that zip files from a folder. I want to make sure that the zipped file is not more than 10 MB. If the size is more than 10MB, it should create another ZIP file. Is there any command (or other method )that can be used for this?

The question has the gzip tag but the text refers to zip, can you clarify? (The answers are divided between approaches based on the different formats.)

I cannot add zip into the tag thats why I used gzip, If you have a gzip method that I can fit with this problem, I can use that too.

3 Answers 3

You can use the «split archive» functionality of «zip» itself using the «—split-size» option.

From «zip» manpage (» man zip «):

(. )

One use of split archives is storing a large archive on multiple remov‐
able media. For a split archive with 20 split files the files are typ‐
ically named (replace ARCHIVE with the name of your archive) AR‐
CHIVE.z01, ARCHIVE.z02, . ARCHIVE.z19, ARCHIVE.zip. Note that the
last file is the .zip file.

(. )

-s splitsize
—split-size splitsize

Split size is a number optionally followed by a multiplier.
Currently the number must be an integer. The multiplier can
currently be one of k (kilobytes), m (megabytes), g (gigabytes),
or t (terabytes). As 64k is the minimum split size, numbers
without multipliers default to megabytes. For example, to cre‐
ate a split archive called foo with the contents of the bar
directory with splits of 670 MB that might be useful for burning
on CDs, the command:

So, to create a split zip archive, you could do the following (the » -r » is the «recursive» switch to include subdirectories of the directory):

Читайте также:  Linux zip files to archive

$ zip -r -s 10m archive.zip directory/

To unzip the file, the » zip » manpage explains that you should use the «-s 0`» switch:

 zip -s 0 split.zip --out unsplit.zip 

will convert a split archive to a single-file archive.

(. )

So, you first «unsplit» the ZIP file using the «-s 0» switch:

$ zip -s 0 archive.zip —out unsplit.zip

. and then you unzip the unsplit file:

Источник

Оцените статью
Adblock
detector