more - Linux


Overview

The more command in Linux is a utility for displaying text files in a terminal one screen at a time. It is commonly used to read long files incrementally and includes navigation functionalities. This tool is most effective for quickly viewing or scrolling through large logs or files directly from the command line.

Syntax

more [options] file...
  • file…: Specifies one or more files to view. Multiple files will be opened one after the other.

Options/Flags

  • -d: Displays a prompt to the user rather than a bell sound when user input is required.
  • -f: Causes more to count logical lines rather than screen lines (lines too long to fit on the screen are not folded).
  • -l: Prevents more from treating the form-feed (ASCII 12) character as a special symbol; more normally pauses after form-feed characters.
  • -c: Redraws the screen by clearing it before displaying a file, rather than scrolling the display to show new text.
  • -p: Redraws the screen by repainting lines rather than scrolling lines into view.
  • -s: Squeezes multiple blank lines into one.
  • -u: Suppresses underlining, which helps when previewing output on terminals that do not support this feature.

Examples

  1. Viewing a File:

    more myfile.txt
    

    This command opens myfile.txt, displaying it page by page.

  2. Combining Options:

    more -c -s document.log
    

    here -c clears each page before showing it, and -s combines multiple blank lines into one. Useful for clean viewing of cluttered log files.

  3. Navigating Across Multiple Files:

    more file1.txt file2.txt
    

    Opens file1.txt and then file2.txt in sequence, allowing navigation through both files using the same session.

Common Issues

  • File Wrapping: Long lines might wrap and make the content difficult to read. Use -f to prevent wrapping of long lines.
  • Escape Characters: Files with many non-printing characters can be hard to read; using -u can improve visibility.

Integration

more is often used in pipelines to view the output of other commands:

ls -l /etc | more

This example lists the detailed contents of /etc and pipes it into more for easy reading.

  • less: An advanced pager with more features that does not require loading the entire file before viewing and allows both forward and backward navigation.
  • cat: Used to concatenate and display files, cat doesn’t provide interactive navigation.
  • head, tail: Display the beginning and the end of files respectively, used for quick lookups rather than full interactive exploration.

For further reading and more detailed information, refer to the Linux manual pages which can be accessed using man more on your terminal.