Merge text files with cat
Join split logs, CSV parts, or chapter files into a single file.
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.txt02What 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
!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 pageEvidence: 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
Search text recursively in a directory with grep
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Extract a .tar.gz archive with tar
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.
Check free disk space on each filesystem with df
Show total, used, and available space plus usage percentage for every mounted filesystem in human-readable units.