Text processing

Linux cat command

Print file contents to the terminal or join multiple files together.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

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

Examples

Write the contents of a text file to standard output.

cat README.md

Display a configuration file with line numbers.

cat -n config.conf

Parameters, options and clauses

Option / clauseDescription
-n, --numberNumber all output lines.
-b, --number-nonblankNumber nonblank output lines.
-s, --squeeze-blankSuppress repeated empty output lines.
-A, --show-allShow nonprinting characters, equivalent to -vET.
-E, --show-endsDisplay $ at the end of each line.
-T, --show-tabsDisplay tab characters as ^I.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory