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 form | What it does |
|---|---|
-n | Number every output line, starting at 1 |
-b | Number only the lines that are not blank. Overrides -n |
-s | Squeeze runs of blank lines down to a single blank line |
-e | Show a $ at the end of each line, and make non-printing characters visible (see -v) |
-t | Show tab characters as ^I, and make non-printing characters visible (see -v) |
-v | Make non-printing characters visible. Control characters appear as ^X, such as ^M for a carriage return |
-u | Do not buffer the output. Useful when another program is waiting on it |
Examples
cat notes.txt
alpha
beta error
gamma
Beta again
error: disk full
delta
cat -n app.log
cat notes.txt words.txt > combined.txt
printf 'header\n' | cat - words.txt
header
pear
apple
pear
fig
apple
apple
cat -te data.csv
cat -sb notes.txt
Notes
- Never write cat a b > a. The shell empties a before cat starts reading, so the original contents of a are lost. Write to a different file.
- A single dash (-) means read from standard input. Without any file name, cat also reads from standard input and waits for you to type. Press Ctrl-D to finish.
- cat prints everything. For a large file, use head, tail or less instead, so you are not flooded with output.
- macOS and GNU/Linux cat differ on the extras. GNU cat has -A (show all), -E (show line ends) and -T (show tabs). On macOS use -e and -t, which also turn on -v.
- A cat in front of another command, as in cat file | grep x, is often not needed. Most commands, including grep, accept a file name directly.
See also
Last reviewed 2026-10-07.