Linux cat Command
What cat is really for, why piping it into grep is a habit worth breaking, and the flags that make it genuinely useful.
Formula
cat [OPTION]... [FILE]...
How to use it
- The synopsis at the top shows the general form of the command.
- Click any example to copy it straight to your clipboard.
- The options table lists only the flags worth remembering — run man for the exhaustive list.
Examples
| cat notes.txt | print a file |
| cat a.txt b.txt > both.txt | join two files into one |
| cat -n script.sh | print with line numbers |
Questions people ask
How do I view a file too long for the screen?
Use less. It scrolls, searches with /, and does not flood your scrollback.
Why does my file show ^M at the end of every line?
It has Windows line endings. Convert it with dos2unix, or strip the carriage returns with tr -d '\r'.
Does this page work offline?
Yes, after the first visit. The whole reference is part of the page and the service worker caches it.
Runs entirely in your browser. Nothing you type is uploaded, logged or shared.
Last updated 22 August 2026