Skip to main content

Command referencecat

cat command (Linux / bash / sh / zsh)

Linuxbashshzshtextbeginner

What it does

Concatenate files and write their contents to standard output. When people search for the cat command linux, they usually want cat's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Concatenate files and write their contents to standard output.

Syntax

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

Common options

Flag / optionMeaning
-nNumber every output line.
-bNumber nonblank lines only.
-AReveal tabs, line endings, and nonprinting characters.
-sCollapse repeated blank lines.

Practical examples

Read a file

cat README.md

Writes the complete file to the terminal.

Join parts

cat part1 part2 > complete.txt

Combines two files into a new file.

Inspect whitespace

cat -A data.txt

Makes hidden spacing characters visible.

Linux ↔ Windows equivalent

Closest match: Get-Content (Windows / PowerShell). Read file content or provider data as a stream of objects.

Common mistakes

  • Using cat for a huge file and flooding the terminal; use less instead.
  • Redirecting output to one of the input files, truncating it before cat reads it.

FAQ

What does cat do in Linux?

Concatenate files and write their contents to standard output.

How do I use cat from the terminal?

Start with `cat [OPTION]... [FILE]...`, then choose only the options needed for the task.

What is a practical cat example?

Try `cat README.md` — Writes the complete file to the terminal.

Can I use cat in a shell script?

Yes. cat works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.