View Files with Syntax Highlighting using bat

Read config files and code in the terminal with bat: syntax colors, line numbers, and git diff markers, with non-interactive output for scripts.

LinuxtextbatcliLow risk
Run bat config.yaml (or batcat on Debian/Ubuntu) to print a file with syntax highlighting and line numbers.

01Command

Command
$ bat --style=numbers,header config.yaml

02What it does

bat renders hundreds of file types with proper syntax highlighting, shows line numbers via --style=numbers, and marks changed lines when inside a git repo. It pipes through a pager for long files — use --paging=never when another tool consumes the output, and -l json to force a language for unknown extensions. Many people alias cat=bat --paging=never for interactive use while keeping plain cat in scripts.

03Risk

RiskLow risk
Requirementsbat (sudo apt install bat / sudo dnf install bat — binary may be named batcat on Debian/Ubuntu)
!Warning: On Debian/Ubuntu the binary installs as batcat, not bat, because of a name conflict — create an alias or symlink if you want to type bat.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • bat — a cat clone with syntax highlighting
    sharkdp (GitHub) · vendor-doc · 2026-09-17
    Evidence: Official README: bat shows files with syntax highlighting, git integration, automatic paging, and the --style options.
  • batcat(1) — Ubuntu manual page
    Canonical · community · 2026-09-17
    Evidence: Documents bat's options including --style, -l language override, and the batcat binary name on Debian/Ubuntu.

Last verified: 2026-09-18 · Category: Developer

06Related solutions