The more command in Linux: paginate file content

Introduction

In the day-to-day work of a system administrator or a developer working in the terminal, it is common to encounter extensive text files: logs, configuration files, command output, etc. Reading all that content at once can be overwhelming and inefficient. That’s why Linux provides several utilities designed to paginate output, allowing you to advance page by page and maintain control over the information displayed. Among these tools, the more command is one of the most classic and simple to use.

What is more?

more is a filter that displays the content of a file or the standard output of another command on the screen, pausing after each full screen. It was created in the early years of Unix and remains present in practically all modern Linux distributions. Its operation is very similar to that of less, but with fewer advanced features; nevertheless, its simplicity makes it an ideal option when you need quick pagination without overloading memory.

Basic Syntax

The simplest way to invoke more is:

more filename

It can also be used with a pipe to paginate the output of any command:

command | more

When executed, more displays the first screen of content and waits for the user to press the space bar to advance a full page, or the Enter key to advance line by line. Other useful keys are b to go back one page (only in some versions) and q to exit immediately.

Most Useful Options

  • -n number: specifies the number of lines to be displayed per screen. For example, more -20 file.txt will show 20 lines per page instead of the terminal’s default size.
  • -d: causes more to display a help message at the bottom of the screen, indicating which keys are available (space, Enter, b, q, etc.). This is especially useful for novice users.
  • -s: squeezes multiple consecutive blank lines into a single one, which can make reading files with many blank lines more comfortable.
  • +number: starts viewing from the indicated line. For example, more +50 file.txt skips the first 49 lines and begins displaying from line 50.

Practical Examples

Suppose we want to review the log file /var/log/syslog, which usually contains hundreds or thousands of lines. A typical command would be:

more /var/log/syslog

If we are only interested in the last 100 lines and want to view them paginated, we can combine tail and more:

tail -n 200 /var/log/syslog | more

To view a long script and skip the first 30 comment lines, we use:

more +30 script.sh

And if we want each screen to show exactly 15 lines, regardless of terminal size, we execute:

more -15 large_file.txt

Limitations and Alternatives

Although more is useful and present on almost any system, it has some limitations. It does not allow free backward scrolling in all its versions (the b key may not work on certain systems), and it lacks advanced search features like those offered by less. When greater interactivity is needed, such as searching for patterns with / or n, moving both forward and backward with the arrow keys, or exiting without losing position, less is usually the preferred option.

Another modern alternative is to use the pg command or even the built-in pagers in editors like vim or nano, but for simple and quick tasks, more remains a lightweight, dependency-free choice.

Usage Tips

  • Always try the help key (-d) if you don’t remember the shortcuts.
  • Combine more with filtering commands like grep, awk, or sort to reduce data volume before paging.
  • In scripts, avoid relying on more for interactive input; better to redirect to a file or use less if you need programmatic control.
  • Remember that more does not modify the file; it is only a viewing method.

Conclusion

The more command remains a valuable tool in the repertoire of any Linux user. Its simplicity, low resource consumption, and universal availability make it ideal for quickly reviewing text files or command output when advanced features are not required. Knowing its options and knowing when to switch to less or other alternatives will allow you to work more efficiently in the terminal.

This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .