A flexible, command-line pager
Command Line – most

© Lead Image © Sergey Jarochkin, 123RF.com
If you like to customize your command-line file pager, check out most.
Many files you may want to view from the command line require more than a single screen to display. As a result, they scroll by too quickly to read and are most conveniently read with a file pager. The oldest surviving pager is the more
[1] command, which has a limited set of options. When a more sophisticated pager was released, it was called less
[2], because, as the old saying goes, "less is more." A third-generation pager continues the joke by being called most
[3], apparently on the ground that most is more than less.
As a joke, the name ranks for better or worse with recursive acronyms like GNU's Not Unix (GNU). However, as a pager, most
offers far more flexibility than less
or more
in viewing, navigation, and customization.
Enabling Display Behaviors
most
is apparently written with the assumption that it will be used most of the time to scan a file's contents. If you simply enter the basic command followed by the file to view, you will notice that the display has some peculiarities (Figure 1). For example, if a line has more characters than most
's terminal width, the lines are truncated with a dollar sign ($
) as the last character in the line. To view the rest of the line, you must use the right arrow key. If you use the -w
option to wrap the line, then a backslash (/
) is added unless you also add the -d
option. So, should you want to view a file without these extra characters, the basic command structure should be:

most -wd FILE
However, you can also enable or disable other aspects of the display. For instance, to save space, you can use the -v
option to have control characters display with a prefix of ^
rather than Ctrl-CHARACTER
. Similarly, the -t
option renders tabs as ^I
. If a file contains several blank lines in a row, you might add -s
to replace them with a single blank line.
If you are referring to the file in detail and moving back and forth in it, another useful option is to add line numbers using +lineno
. Still another option is to view the file as binary using -b
(Figure 2). When you want to find a certain passage in a long file, you can also use the option +/STRING
to jump directly to a keyword or phrase, further refining the search by making it case-sensitive with -c
.
If you are looking at files to decide what to delete, still another useful option is +d
. With this option enabled, you can activate a toggle once the file is open to delete it after confirming the action.
Other options that you can toggle while viewing a file include :c
for case sensitivity and :o
or :O
, which allows you to add b
(binary), d
(selective display), t
(tab), v
(verbose), or w
(wrap). Without these toggles, upon discovering a need for these options, you would have to exit and edit the command to use them.
Navigating Basics
While viewing a file in most
, you can navigate with just the Up and Down arrow keys and close the file with Q, Ctrl+X, or Ctrl+C – whichever you prefer. Each time you press an arrow key, the cursor moves one line. However, if you enter a number before pressing an arrow key, you will move that number of lines.
By default, most
displays in a 60-column line, truncating the rest of the line. You can view the rest of the line with the right arrow plus the Tab key, or the left arrow plus Ctrl+B, depending where the cursor is on the line.
You can make larger jumps in the displayed file, too. T+Esc takes you to the top of the file and B+Esc to the bottom. When the file displays over several windows, you can use the structure NUMBER%
(such as 3%) to jump to a specific spot in the file. If you are moving back and forth in a file, you can use Ctrl+@ or Ctrl+K to add a bookmark to the current line. Once you have one bookmark, you can return to it by pressing Ctrl+X or Ctrl+K+Enter, which also creates another bookmark at your current position if one does not already exist.
Working with Multiple Files
With all these options for viewing a file, you might almost overlook the fact that a single instance of the command can deal with multiple files. Working with multiple files isn't made easier by the fact that most
's man pages eke out information by separate snippets. Some users, too, might wonder whether the reference to displaying each file refers to a separate terminal or a separate screen of information (which is actually the case).
However, once you piece the information together, working with multiple files is straightforward. All that is required is a space-separated list of filenames in the command. If you want, you can specify the same file twice, so you have convenient access to different passages.
To move between multiple files, you can toggle :n
to move to the next file in the list, selecting it by pressing any key except Q. Each file can have its own separate options for display, and can be searched separately. However, you can toggle L to lock each file, which is indicated by an asterisk (*
) on the left of the status bar at the bottom of the display. All windows that are locked will scroll together, a feature that can help you compare two copies of a file for differences.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs
News
-
LibreOffice 7.5 has Arrived and is Loaded with New Features and Improvements
The favorite office suite of the Linux community has a new release that includes some visual refreshing and new features across all modules.
-
The Next Major Release of Elementary OS Has Arrived
It's been over a year since the developers of elementary OS released version 6.1 (Jólnir) but they've finally made their latest release (Horus) available with a renewed focus on the user.
-
KDE Plasma 5.27 Beta Is Ready for Testing
The latest beta iteration of the KDE Plasma desktop is now available and includes some important additions and fixes.
-
Netrunner OS 23 Is Now Available
The latest version of this Linux distribution is now based on Debian Bullseye and is ready for installation and finally hits the KDE 5.20 branch of the desktop.
-
New Linux Distribution Built for Gamers
With a Gnome desktop that offers different layouts and a custom kernel, PikaOS is a great option for gamers of all types.
-
System76 Beefs Up Popular Pangolin Laptop
The darling of open-source-powered laptops and desktops will soon drop a new AMD Ryzen 7-powered version of their popular Pangolin laptop.
-
Nobara Project Is a Modified Version of Fedora with User-Friendly Fixes
If you're looking for a version of Fedora that includes third-party and proprietary packages, look no further than the Nobara Project.
-
Gnome 44 Now Has a Release Date
Gnome 44 will be officially released on March 22, 2023.
-
Nitrux 2.6 Available with Kernel 6.1 and a Major Change
The developers of Nitrux have officially released version 2.6 of their Linux distribution with plenty of new features to excite users.
-
Vanilla OS Initial Release Is Now Available
A stock GNOME experience with on-demand immutability finally sees its first production release.