Page Long Terminal Output with more Without Losing Your Place

You will use more to read a long file or command output one screenful at a time, search within it, and leave the pager cleanly. The examples use the more supplied by util-linux. Allow about ten minutes for the basic workflow, or a little longer if you need to diagnose terminal or environment settings.

Prerequisites: a Linux shell, a terminal, and a readable text file. The examples do not need elevated privileges. Keep sudo out of this workflow unless the file itself is deliberately restricted and you have permission to read it.

1. Confirm which more you are running

The installed command on this machine is util-linux 2.41.3. The local manual page identifies the documented source as util-linux 2.39.3, so small details can vary between releases. Check your executable and version before relying on a script:

$ command -v more
/usr/bin/more
$ more --version
more from util-linux 2.41.3

more is a pager, not an editor: it reads a file and displays it in the terminal, and never writes back to it.

2. Open a file and move through it

Start with a path that exists on your system:

$ more /path/to/long-file.txt

more displays the first screen and waits for a command. Press the space bar for another screenful. Press Return for one more line. Press q to quit. If you forget the controls, press h or ? for the built-in help.

For a file, b goes back one screenful and f goes forward one screenful. The backward command does not work when the input is a pipe, because a pipe normally cannot be revisited. Press f when you want to skip forward without reading each screen.

Checkpoint: open a real text file, press space once, then press q. You should return to your shell prompt without a changed file.

3. Choose the starting point or screen size

Use +number to start at a line, or +/pattern to search for a pattern before displaying the file:

$ more +120 /path/to/long-file.txt
$ more '+/ERROR' /path/to/application.log

Quote the +/pattern form so the shell passes it as one argument and does not interpret characters in a more complicated pattern. The search form starts at the first matching occurrence that more finds. It is a starting position, not a replacement for a full log-search tool.

If the terminal is unusually small, specify the number of lines per screen with -n:

$ more --lines 12 /path/to/long-file.txt

A bare numeric option has the same meaning, so more -12 file.txt is equivalent to more --lines 12 file.txt. Prefer the long form in scripts because it makes the intent obvious. The value must be a positive decimal integer.

4. Search while the pager is open

When more is already displaying a file, type /pattern and press Return. The pattern is a regular expression according to the manual. Press n to search for the next occurrence of the last pattern. The ' command returns to the place where the last search started, and = prints the current line number.

$ more /var/log/example.log
/timeout
n
=

Those input lines are shown as a reminder of the keys, not as commands to paste into the shell. While the pager owns the terminal, type the key or key sequence directly. A failed search may leave you at the end of the input, so use ' or reopen the file if you need to return to the search origin.

5. Page command output without creating an intermediate file

Use a pipe when you want to inspect output from another command:

$ journalctl --no-pager | more
$ find /etc -maxdepth 1 -type f -print 2>/dev/null | more

These commands only read or list data. The second example hides errors for paths that cannot be read, so it is useful for a quick inventory but not for a complete audit. If you need every error, remove the redirection and read the diagnostics separately.

For a finite command, the pipe is often enough. Do not expect b to move backwards through piped input. If you need reliable backwards movement or repeated inspection, save output to a new file first, then open that file with more. Use a new destination name rather than blindly redirecting over a useful file.

6. Make routine viewing less noisy

Several options change presentation without changing the input:

-u suppresses underlining, but the manual says this option is silently ignored for backwards compatibility. Do not add it expecting a visible effect on this util-linux implementation.

You can set preferred options in the MORE environment variable, but the manual requires those options to include a leading dash. Command-line options override values from MORE. If a colleague's terminal behaves unexpectedly, inspect that variable:

$ printf '%s\n' "${MORE-}"

For a one-off command, command-line options are easier to see and review than hidden environment state.

7. Treat interactive escape commands as powerful

The more prompt accepts !command and :!command to execute a command in a subshell. It also accepts v to start an editor, selected from VISUAL, then EDITOR, then vi. These are intentional capabilities, but they are easy to trigger in a shared or untrusted terminal session. Do not press them casually, and review VISUAL, EDITOR and SHELL before using them on sensitive material.

If you only need to read text, q, space, Return, search, and the movement keys are sufficient. Exiting the pager does not undo any command already launched with ! and does not undo edits made through v. If an accidental command changed state, use that command's own recovery procedure and check its result before continuing.

8. Diagnose the common surprises

If more exits immediately, check whether its input is empty, whether the file is readable, and whether you are running it non-interactively. The -e option exits at end-of-file and is enabled by default when POSIXLY_CORRECT is not set or when the command is not running on a terminal. Setting POSIXLY_CORRECT disables that default. A script should not assume that an end-of-file pause will always be present.

$ test -r /path/to/long-file.txt && printf '%s\n' readable
$ printf 'MORE=%s\nPOSIXLY_CORRECT=%s\n' "${MORE-}" "${POSIXLY_CORRECT-}"

If the display is garbled, check TERM. It tells more which terminal characteristics to use. A missing or incorrect terminal type is an environment problem, not a reason to edit the input file. If the output contains formatting you do not want, try -s, -f, or -c for the specific behaviour you need.

Done means