Skip to content
Latchkey

split -b: Split a File by Byte Size

split -b divides a file into chunks of a fixed byte size, regardless of line boundaries.

When a system caps upload or artifact size, split -b cuts a file into pieces that each fit under the limit.

What it does

split -b SIZE writes fixed-size byte chunks, accepting suffixes like K, M, G (powers of 1024) and KB, MB (powers of 1000). -b splits anywhere, even mid-line; -C SIZE instead makes each chunk at most SIZE bytes but never splits a line, which is safer for text.

Common usage

Terminal
split -b 10M big.bin part_              # 10 MiB pieces
split -b 50MB upload.tar piece_         # 50 MB (decimal) pieces
cat part_* > rejoined.bin               # reassemble in order
split -C 1M -d log.txt chunk_           # <=1M, no split lines

Options

FlagWhat it does
-b SIZEBytes per chunk (K/M/G = 1024, KB/MB = 1000)
-C SIZEMax bytes per chunk without splitting a line
-dNumeric suffixes
-a NSuffix length
--additional-suffix=<s>Append an extension

In CI

split -b keeps artifact pieces under an upload cap; cat part_* reassembles them in suffix order. Mind the units: 10M is 10 MiB (1024-based) while 10MB is 10 MB (1000-based), which matters when the limit is exact.

Common errors in CI

Reassembly with cat part_* relies on shell glob order, which is correct only if suffixes sort lexically; keep -a wide enough that they do. -b can cut a multibyte character or a line in half, so use -C for text you will process line by line. Decimal vs binary suffixes (MB vs M) trip size-limit checks; pick the one the target system means.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →