Online Linux Terminal Logo
OnlineLinuxTerminal
文件操作CLI Manual

$cat

连接文件并在终端标准输出上打印文件内容。

命令语法POSIX Standard
cat [OPTIONS] [FILE...]
Linux 社区2.4k 在线

与真实 Linux 用户交流,学习常用命令并免费获取精美速查表 PDF。

在交互式终端沙盒中实时运行

无需安装的客户端实时仿真环境。

在全屏终端工作区中打开 ↗
bash — terminal

概述与工作原理

cat 用于快速查看或合并文本文件内容,常与重定向和管道结合使用。

常用参数与选项说明

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.

实际生产案例与代码范例

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

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

#2Inspect OS release configuration
cat /etc/os-release

Displays Linux distribution and kernel release information.