How to split a gzip file to several small ones on Linux?

Posted on In QA

I have a very large (e.g. 100GB) .gz file and would like to split it into smaller files like 8GB/each for storage/copying. How to split a gzip file to several small ones on Linux?

You may use the tool split to split a file by sizes.

An example to split a large.tgz to at most 8GB smaller files is as follows.

split -b 8G large.tgz large.tgz.part-

The split files names are the prefix with appendix like ‘aa’, ‘ab’, ‘ac’ as follows.

$ ll -h
total 35G
-rw-rw-r-- 1 user user  18G Jun 25 10:57 large.tgz
-rw-rw-r-- 1 user user 8.0G Jun 25 12:10 large.tgz.part-aa
-rw-rw-r-- 1 user user 8.0G Jun 25 12:15 large.tgz.part-ab
-rw-rw-r-- 1 user user 1.2G Jun 25 12:16 large.tgz.part-ac

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

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