Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux more Command: Display File Content by Paging

The more command is a basic Linux command that allows you to view the contents of a text file, one screenful at a time. This can be helpful when you want to quickly read through a large file without loading the entire file into memory. In this tutorial, we will cover how to use the more command with various options.

Basic Usage

To use the more command, simply type more followed by the file name. For example, to view the contents of a file called example.txt, you would use the following command:

more example.txt

This command displays the contents of example.txt one screenful at a time. You can use the following keys to navigate through the file:

  • Space: Move to the next screenful of text.
  • Enter: Move down one line at a time.
  • b: Move back one screenful of text.
  • q: Quit more and return to the command prompt.

Display Line Numbers

To display line numbers alongside the text, use the -n or --number option. For example, to view the contents of example.txt with line numbers, you would use the following command:

more -n example.txt

View Multiple Files

You can view multiple files one after the other by specifying the file names separated by spaces. For example, to view the contents of file1.txt and file2.txt, you would use the following command:

more file1.txt file2.txt

After reaching the end of the first file, press Enter to continue to the next file.

Set Custom Screen Size

By default, more uses the terminal window size to determine the number of lines displayed per screen. To set a custom screen size, use the -s or --screen-size option followed by the number of lines. For example, to display 10 lines at a time for example.txt, you would use the following command:

more -s 10 example.txt

Pipe Output to more

You can pipe the output of other commands into more for convenient viewing. For example, to view the output of the ls -la command one screenful at a time, you would use the following command:

ls -la | more

Conclusion

The more command is a simple but useful tool for viewing the contents of text files in a terminal environment. By using various options, you can display line numbers, view multiple files, set custom screen sizes, and pipe the output of other commands. While more is a valuable utility, more advanced tools like less offer additional features such as bidirectional scrolling and better performance with large files.

  1. How to use the more command to display file content: To display the content of a file in the Linux terminal using more, simply type:

    more filename.txt
    
  2. Displaying text files page by page with more: View text files page by page using more. For example:

    more long_text_file.txt
    
  3. more command examples and usage in Linux: Explore various usages of the more command. For instance:

    more -10 filename.txt  # Display ten lines at a time
    
  4. Advanced options for the more command in Linux: more offers advanced options. For example:

    more +/search_pattern filename.txt  # Start displaying from the line containing the search pattern
    
  5. more vs. less command in Linux: While more is useful for basic navigation, less is more feature-rich. Still, you can use more in a pipeline. For example:

    cat filename.txt | more
    
  6. Paging through logs with more in Unix-like systems: Use more to page through log files in Unix-like systems:

    more /var/log/syslog