Comment

Comment by freddie_mercury

>> That allows you to concatenate and page multiple files at once like bat does? >cat is literally called “cat” because it’s intended purpose is concatenation.

cat's behaviour and bat's behaviour is different, though.

  >cat a.txt b.txt                                                                                                                                                                                         
  It was a dark and stormy night.
  Once upon a time.

  >bat a.txt b.txt
  ───────┬──────────────────────────────────────────────────────
         │ File: a.txt
  ───────┼──────────────────────────────────────────────────────
     1   │ It was a dark and stormy night.
  ───────┴──────────────────────────────────────────────────────
  ───────┬──────────────────────────────────────────────────────
         │ File: b.txt
  ───────┼──────────────────────────────────────────────────────
     1   │ Once upon a time.
  ───────┴──────────────────────────────────────────────────────
This difference becomes more useful once we have a more meaningful example:

  >cat *.py
  (thousands of lines of output)

  >bat -r :5 -H 2 --style full *.py
  ───────┬──────────────────────────────────────────────────────
         │ File: __init__.py   <EMPTY>
         │ Size: 0 B
  ───────┴──────────────────────────────────────────────────────
  ───────┬──────────────────────────────────────────────────────
         │ File: editor.py
         │ Size: 2.4 KB
  ───────┼──────────────────────────────────────────────────────
     1   │ import collections
     2   │ import contextlib
     3   │ import glob
     4   │ import io
     5   │ import os.path
  ───────┴──────────────────────────────────────────────────────
It's hard to imagine many people have the muscle memory for the combination of cat, head, and whatever else you need to add headers with the filename and file size, call out empty files, highlight the second line, show line numbers, do syntax formatting, and wrap to the terminal width (head doesn't do this).

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton