If you don’t like the dull and boring output of the cat command, consider installing bat on your Linux machine.
The cat utility predates Linux, but you might wonder if there's something better than this standard utility. If you want to examine files in Linux, there's a newer utility named bat that you might be interested in.
bat is a clone of cat with some modern features. The tagline on its GitHub page is "a cat clone with wings."
One major feature is the addition of line numbers to any output. It also automatically recognizes several programming languages and highlights syntax. It also integrates seamlessly with Git.
Installing bat on a Linux desktop is easy enough. It's available in many Linux distribution's official repositories.
To install bat on Ubuntu or Debian, just use APT:
Running it on Debian and Ubuntu is a little different, as will be explained later.
To install bat on Arch Linux:
And on Fedora/Red Hat/CentOS:
Running bat is similar to using cat. You can use it with files or with standard input. You can call it at the command line with "bat."
If you're on Ubuntu or Debian, call it by typing "batcat" instead. You can change it back to "bat" by creating a shell alias with:
Stick this in your shell configuration file (usually .bashrc or .zshrc) to make it permanent.
The first thing you'll notice is that bat draws a border around the output with line numbers. This seems to just make it prettier. The standard cat program does have the -n option to display line numbers.
If you don't like the decorations, you can use the -n to only display line numbers.
bat will detect many popular programming languages and highlight the syntax. You can use the -l option to force the detection of a particular language, such as C.
bat is a modern alternative to the classic Linux cat command. It offers some unique features, such as pretty-printing line numbers, paging, and syntax highlighting.
bat is not the only modern take on classic Unix utilities out there. There are many replacements for time-tested utilities like grep or man that you might want to check out.
David is a freelance writer based in the Pacific Northwest, but originally hailing from the Bay Area. A journalist by training, he discovered the power of Unix-like operating systems and the command-line interface while learning how to edit video on macOS. He has been using Linux regularly in some form since 2006. David has been able to combine his passion for computing and writing in his career as a freelance writer. His writing has appeared in Techopedia, TMCnet, and the Motley Fool blog network. David holds a B.A. in communication from California State University, East Bay.