Operations 7 min read

Master Linux File Splitting and Merging with split and cat Commands

Learn how to efficiently split large files into smaller chunks and recombine them on Linux using the split and cat commands, with detailed syntax options, practical examples, and tips for handling line counts, byte sizes, numeric suffixes, and progress monitoring.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux File Splitting and Merging with split and cat Commands

File Splitting with split

Linux provides the split utility to break a large file into smaller pieces that can be transferred independently and later reassembled.

Syntax

split [OPTIONS] [INPUT_FILE] [PREFIX]

Key options

-a N

– suffix length (default 2, produces aa, ab …) -d – use numeric suffixes starting at 0 -l LINES – split after each LINES lines (default 1000) -b SIZE – split by byte size; SIZE may use K, M, G, … (powers of 1024) or KB, MB … (powers of 1000) -C SIZE – split by byte size while preserving whole lines (no line is broken) --additional-suffix=SUF – append an extra suffix to each output name --elide-empty-files – do not create empty output files --filter=CMD – pipe each chunk to CMD instead of writing a file --verbose – print progress information

Typical usage

# Split a 300 000‑line SQL dump into 300 000‑line chunks
split -l 300000 users.sql /data/users_

# Same, but numeric suffixes (users_00, users_01 …)
split -d -l 300000 users.sql /data/users_

# Split by size, 100 MiB per file, numeric suffixes
split -d -b 100m users.sql /data/users_

Notes on size units

SIZE may be an integer followed by an optional unit. Units K, M, G, T, P, E, Z, Y represent powers of 1024; the suffixes KB, MB, … represent powers of 1000. Example: 100m = 100 MiB (100 × 1024 × 1024 bytes).

File Merging with cat

After splitting, the cat command concatenates the pieces back into the original file.

Syntax

cat [OPTIONS] [FILE]...

Common options

-n

– number all output lines -e – display $ at end of each line -t – display TAB characters as

^I

Reassembly example

# Reassemble the split files into the original dump
cat /data/users_* > users.sql

Important considerations

Use a glob pattern that matches the split files in the correct lexical order; numeric suffixes guarantee proper ordering (e.g., users_00, users_01).

If the split was performed with -C (line‑preserving), the reassembled file will be byte‑identical to the original.

Both utilities belong to GNU coreutils; documentation is available at http://www.gnu.org/software/coreutils/.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CATfile managementsplit
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.