The Bash logo

The real differences between less, more, and most

1

In UNIX and Linux, a pager is an application for your terminal that lets you scroll through large documents. This is significant because by default terminal output is sent directly to your terminal, and many users set their terminals to retain only 1,000 lines or so of scrollback history.

The easy answer to the problem of text scrolling off screen before you can read it is to intercept the text with a pager application, which stores the entire file in memory and gives you controls so you can scroll forwards and backwards through the document. In early editions of BSD, the more pager handled this, but later the less and most pagers were released to add different features.

I spent a year using most as my exclusive pager on Slackware, and less as my pager on my Fedora laptop, and more as the pager on my servers. Here’s what I’ve discovered.

The more command

Like any pager, more takes over your terminal in order to display the contents of a file or pipe. However, more automatically quits once it ends the end of the file or pipe, so there’s no confusion about how to exit it. For new users, this can be a real advantage.

If you’re an experienced user, you probably take it for granted that a pager overtakes your terminal and locks you into its interface, but to someone who’s not used to the terminal interface, getting out of a pager can be as baffling as exiting vim.

Basic more control is intuitive. You scroll down (by a screenful) with the Down Arrow, and you’re returned to a terminal prompt when you reach the end of the file. Precision scrolling requires 2 key presses. First, enter a digit to set the value of k, and then press S on your keyboard to scroll down k lines. The default value of k is 11, so you must press 1s to scroll 1 line.

There are many scroll options. You can scroll by line or by screen, or skip to a specific line number. Behaviour differs depending on whether you’re looking at a file or a pipe. For example, you can scroll up using B when viewing a file, but you can’t scroll up at all when viewing a pipe.

Advanced more features

The ! key places you into a subshell, so you can run a command without closing more. This is a nice feature, providing you with an on-demand multiplexer in case you’re not already running one.

The v key starts $EDITOR or $VISUAL or vi (in that order of priority) at the current line. However, because more quits at the end of a file, this trick doesn’t work on very short files, and of course it doesn’t work on a pipe.

The more pager

The more interface is minimal, which I think can be both good and bad. If all you want out of your pager is to easily scroll from the top of output to the end of output, then more meets your requirement. It’s even got a few bonuses, like the ability to run a subshell without exiting, or launching an editor at your current position in a file.

If you want precise controls, however, more demands extra key presses or just fails to provide.

The less command

As the joke goes, less is more. And it’s true. Describing the less pager is like describing more, plus a bunch of added features.

Everything more provides is also included in less, including the ! subshell shortcut and opening an editor with the v key.

In addition to everything more has, less gives you precise control regardless of whether you’re viewing a file or a pipe. You can use the Arrow keys on your keyboard to scroll up or down a line, or press the Spacebar to scroll down a screen. You can enter a number before a key press to scroll a specific number of lines or screens.

You can use the --mouse option so you can scroll through a file using your mouse. With the --wheel-lines option, you can set the number of lines for each scroll.

It has features to help you keep track of where you are in a file as you read. When you launch less with the --hilite-unread (-w for short) option, the first unread line is highlighted after you move forward or back a full page.

You can load several files into less at once by listing files when you launch less:

$ less file-01.txt file-02.txt file-03.txt 

Alternately, you can use a keyboard shortcut while less is running.

  • :e or E opens a new file
  • :p displays the previous file
  • :n displays the next file
  • :d removes the current file from the file list

To exit the less interface, you press Q. However, if you prefer the way more quits at the end of the file, the you can launch it with the --QUIT-AT-EOF option.

The less pager

The less pager successfully reimplements all features of more, and much more (pun intended).

The most command

If more is a minimalist pager and less has everything you could ever want in a pager, then most continues the tradition of inaccurate names and sits somewhere in between. For the bulk of its usage, the most pager is a lot like more. You can advance either by line or by screen, you can search forward or backward through a file, and open a file in your default editor.

The unique feature of most is its ability to split its window, the way Emacs or GNU Screen does, so you can view multiple files at once. You can also “lock” two files together so that when you scroll in one window pane, all locked files scroll.

  • Ctrl+X 2 creates a horizontal split.
  • Ctrl+O moves your cursor to another pane within the window.
  • Ctrl+L places a “lock” on a pane. Locked panes scroll together.

It’s a nice feature for comparing files, although it lacks the functions of a dedicated diff viewer.

To quit most, press Q. There’s no way to configure it to quit at the end of a file the way more does.

The most pager

The most pager has more features than more but less than less.

Which pager is right for you

The man pages for more and most aren’t likely to overwhelm you, while less is packed with features. Additionally, the more pager is probably the best option for users inexperienced because its controls are intuitive, and it automatically quits at the end of a file. If you’re looking for an advanced pager, though, then less probably can do what you need.

Regardless of which pager you try next, this article has only been an overview of key features. There’s more to each one, so read their man pages, try some new options, and spend a little time with each before you make a decision.