Split Large File
Table of Contents
# Split bigfile.pdf into chunks of 3MB and append one character to each chunk
split -a 1 -b 3m bigfile.pdf smallfile
-a
how many characters we want to append to each file-b
size of each chunk
# Reassemble the file
cat smallfile{a..d} > newbigfile.pdf
Example #
❯ ls -hl
total 18432
-rw-r--r-- 1 david staff 9.0M Sep 9 09:41 bigfile.pdf
❯ split -a 1 -b 3m bigfile.pdf smallfile
❯ ls -hl
total 36864
-rw-r--r-- 1 david staff 9.0M Sep 9 09:41 bigfile.pdf
-rw-r--r-- 1 david staff 3.0M Sep 9 09:41 smallfilea
-rw-r--r-- 1 david staff 3.0M Sep 9 09:41 smallfileb
-rw-r--r-- 1 david staff 3.0M Sep 9 09:41 smallfilec
❯ cat smallfile{a..c} > newbigfile.pdf
❯ ls -hl
total 55296
-rw-r--r-- 1 david staff 9.0M Sep 9 09:41 bigfile.pdf
-rw-r--r-- 1 david staff 9.0M Sep 9 09:41 newbigfile.pdf
-rw-r--r-- 1 david staff 3.0M Sep 9 09:41 smallfilea
-rw-r--r-- 1 david staff 3.0M Sep 9 09:41 smallfileb
-rw-r--r-- 1 david staff 3.0M Sep 9 09:41 smallfilec
❯ shasum -a 256 bigfile.pdf newbigfile.pdf
5ed1980de1fadbc262c0e1a4ecec1f5374d6b1063814fa5f036f79ff8a66e281 bigfile.pdf
5ed1980de1fadbc262c0e1a4ecec1f5374d6b1063814fa5f036f79ff8a66e281 newbigfile.pdf
On Fedora #
# Split bigfile.pdf into chunks of 3MB and append one digit to each chunk
split -a 1 -b 3M -d bigfile.pdf smallfile
-a
how many characters we want to append to each chunk-b
size of each chunk-d
use digits for naming each chunk
# Reassemble the file
cat smallfile{0..2} > newbigfile.pdf
# Check hash
sha256sum bigfile.pdf newbigfile.pdf