Split a large file into chunks

Low risk
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Splits a large file into fixed-size chunks that fit upload or attachment limits, and shows how to reassemble them into the original file.

filessplitchunkstransfer

Parameters

File to split.

Chunk size, e.g. "100m" or "1g".

Commands

Check the file's size to know how many chunks to expect

ls -lh "<file>"

Split the file into fixed-size chunks named <file>.part-aa, -ab, …

split -b 100m "<file>" "<file>.part-"

Verification

cat "<file>".part-* | shasum -a 256 && shasum -a 256 "<file>"

The hash of the concatenated chunks equals the hash of the original file.

Undo

Delete the chunks; the original file was never modified

rm "<file>".part-*

Pitfalls

  • Reassemble with "cat file.part-* > file" on macOS/Linux, or "cmd /c copy /b file.part-000+file.part-001+... file" on Windows (binary-safe); chunk names sort correctly by design.
  • The chunks together occupy the same space as the original — ensure enough free disk before splitting.
  • The PowerShell variant uses a fixed 100 MB chunk size; adjust the byte-array size for other sizes.

Related