← 返回命令列表

Linux command

bat 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

View

bat [file.js]

Show

bat -n [file.py]

Show

bat -A [file.txt]

Plain

bat -p [file.log]

Multiple files

bat [file1.rs] [file2.rs]

Specific language

bat -l [python] [script]

说明

bat is a cat clone with syntax highlighting and Git integration. It displays file contents with automatic language detection, line numbers, and Git diff indicators in the margin. The tool provides a more user-friendly file viewing experience for developers and system administrators.

参数

-n, --number
Show line numbers
-A, --show-all
Show non-printable characters
-p, --plain
Plain mode (no decorations)
-l, --language _lang_
Specify language for syntax highlighting
-H, --highlight-line _n_
Highlight specific lines
--paging _when_
When to use pager (auto, always, never)
--style _components_
Configure output style
--theme _name_
Color theme
--list-languages
List supported languages
--list-themes
List available themes

FAQ

What is the bat command used for?

bat is a cat clone with syntax highlighting and Git integration. It displays file contents with automatic language detection, line numbers, and Git diff indicators in the margin. The tool provides a more user-friendly file viewing experience for developers and system administrators.

How do I run a basic bat example?

Run `bat [file.js]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -n, --number do in bat?

Show line numbers