Online Linux Terminal Logo
OnlineLinuxTerminal
File OperationsCLI Reference

$cat

Concatenate and print file contents directly to the terminal standard output.

Syntax DefinitionPOSIX standard
cat [OPTIONS] [FILE...]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `cat` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

Overview & How cat Works

The `cat` utility (short for "concatenate") reads files sequentially and prints their contents to stdout. Beyond displaying file contents, `cat` is widely used with redirection operators (`>` and `>>`) to merge multiple files into one, create new text files, or append text logs.

Common Flags & Command Options

Flag / OptionDescription
-nNumber all output lines starting from 1.
-bNumber only non-blank output lines.
-sSqueeze multiple consecutive blank lines into a single blank line.
-EDisplay a dollar sign ($) at the end of each line.

Practical Real-World Examples

Example #1Display file contents with line numbers
cat -n welcome.txt

Reads welcome.txt and prints each line prefixed with its line index.

Sample Output:
1 ===================================================== 2 WELCOME TO ONLINE LINUX TERMINAL 3 =====================================================
Example #2Inspect OS release configuration
cat /etc/os-release

Displays Linux distribution and kernel release information.

Frequently Asked Questions

How do you view large files without filling the terminal?

For large files, use `head` or `tail` instead of `cat` so you can inspect specific portions of output.