A flexible, command-line pager
Command Line – most
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
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.