Meet bat – A Better cat Command for Modern Linux Users

Meet bat – A Better cat Command for Modern Linux Users

- 4 mins

Introduction

The classic cat command has been a staple of Unix-like systems for decades, used to print file contents in a simple, no-frills way. But if you’re craving something more powerful, stylish, and developer-friendly, then meet bat — a modern replacement with wings.

bat isn’t just a pretty face; it adds line numbers, syntax highlighting, paging, and even Git integration to your file-viewing experience — all while being compatible with how you’d normally use cat.


Why Use bat?

🗒️ Think of it as cat on steroids — ideal for developers and power users alike.


Installing bat on Linux

bat is available in the official repositories of most major Linux distributions.

🐧 Ubuntu / Debian

sudo apt install bat

bat

✅ Note: On Ubuntu/Debian, the binary is called batcat. You’ll need to alias it manually if you want to call it as bat.

🏹 Arch Linux

sudo pacman -S bat

🟥 Fedora / RHEL / CentOS

sudo dnf install bat

⚙️ Setting Up Alias (Ubuntu/Debian)

By default, on Debian-based distros, you’ll invoke the command using batcat:

batcat filename.txt

Want to use bat instead? Set up an alias:

alias bat="batcat"

To make it permanent, add it to your shell config file (~/.bashrc, ~/.zshrc, etc.):

echo "alias bat='batcat'" >> ~/.bashrc
source ~/.bashrc

Usage Examples

Just like cat, you can view file contents:

batcat file.txt

bat

Show Line Numbers Only

If you prefer minimal visuals:

batcat -n file.txt

bat

💡 Force Syntax Highlighting

bat auto-detects file types, but you can also manually set the language:

batcat -l python script.py
batcat -l c hello.c

View Multiple Files

You can pass multiple files, just like with cat:

batcat file1.sh file2.sh

Pipe Output or Use with Other Commands

Works seamlessly with pipes and standard input:

echo "Hello, bat!" | batcat

bat


Custom Themes and Configuration

bat supports different syntax highlighting themes. To list available themes:

batcat --list-themes

Choose one by setting it via the config file or environment variable:

export BAT_THEME="TwoDark"

You can also create a bat config at ~/.config/bat/config.

Example:

--theme="TwoDark"
--style="numbers,changes,header"

bat


Summary

batcat is an awesome upgrade over the traditional cat command, especially for developers and sysadmins who spend their day in the terminal. It keeps everything you love about cat while adding modern capabilities that make reading code and config files a joy.

If you’re customizing your CLI toolkit, bat is a no-brainer.


More Tools Like bat

Love tools like bat? Check out other modern replacements:


📘 Official Resources


Thanks for reading! If bat earns a spot in your daily workflow, let me know what theme you’re rocking!

👍 🦇 🚀

— Guneycan Sanli

Guneycan Sanli

Guneycan Sanli

A person who like learning, music, travelling and sports.

comments powered by Disqus