cat Print and join files

Reads one or more files and writes their contents to the screen, one after the other. Use it to look at a short file, to join files together, or to feed a file into another command.

Synopsis

cat [OPTION]... [FILE]...

Common options

Option or formWhat it does
-nNumber every output line, starting at 1
-bNumber only the lines that are not blank. Overrides -n
-sSqueeze runs of blank lines down to a single blank line
-eShow a $ at the end of each line, and make non-printing characters visible (see -v)
-tShow tab characters as ^I, and make non-printing characters visible (see -v)
-vMake non-printing characters visible. Control characters appear as ^X, such as ^M for a carriage return
-uDo not buffer the output. Useful when another program is waiting on it

Examples

Show a file
cat notes.txt
alpha
beta error
gamma
Beta again
error: disk full
delta
Show a file with line numbers
cat -n app.log
Join two files into a new one
cat notes.txt words.txt > combined.txt
Add a heading line in front of a file
printf 'header\n' | cat - words.txt
header
pear
apple
pear
fig
apple
apple
Reveal hidden tabs and line endings
cat -te data.csv
Number lines, skipping blank ones, and squeeze repeated blank lines
cat -sb notes.txt

Notes

See also

Last reviewed 2026-10-07.