Merge text files with cat

Join split logs, CSV parts, or chapter files into a single file.

LinuxFilestextLow risk
Run cat file1.txt file2.txt > combined.txt — files are joined in the order you list them.

01Command

Command
$ cat chapter1.txt chapter2.txt chapter3.txt > book.txt

02What it does

cat concatenates its arguments byte for byte, and > redirects the stream into a new file. Order matters: the first file's content comes first. Wildcards work too — cat part*.txt > all.txt merges every file matching the pattern in alphabetical order.

03Risk

RiskLow risk
!Warning: Do not use an output name that matches one of the inputs: cat a.txt b.txt > a.txt wipes a.txt before it is read. If the source files lack trailing newlines, the last line of one file will fuse with the first line of the next.

04Undo

Undo
$ rm book.txt (the merged file; originals are untouched)

05Sources

  • cat(1) — Linux manual page
    man7.org · community · 2026-09-17
    Evidence: cat concatenates the files named on the command line and writes them to standard output; redirection with > saves the result to a file.

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions