Linux more Command With Examples

The “more” command allows users to visualize the contents of a text file in one place. It is useful for viewing large text files that may not fit on a single screen or for quickly scrolling through the contents of a file.

This guide will demonstrate the “more” command with possible examples in Linux. The content of this tutorial is mentioned below:

Let’s start the “more” command.

How Does the “more” Command Work in Linux?

The “more” command has several options to customize its behavior. Here is the basic syntax for using the “more” command:

$ more [options] [file]

Users can use the -d option with the name of the file to display a message at the bottom of the screen or the -f option to force more to treat long lines as multiple lines.

To see a complete list of options, you can use the “–help” utility.

$ more --help

Let’s explore the “more” commands with implementation.

Example 1: View Content of File at One Screen

To use the more command, you can simply enter more followed by the name of the file you want to view:

$ more file.txt

This will display the contents of file.txt one screen at a time.

Example 2: View the File Content Starting at Specific Line Number

To view the contents of a file starting at a specific line number (i.e., 5), execute the below script:

$ more +5 file.txt

This will display the contents of “file.txt” starting at line number 5.

Example 3: View the Contents of Multiple Files

To view the contents of multiple files consecutively, specify the names of files as below:

$ more file.txt file2.txt

This will display the contents of file1.txt, followed by file2.txt.

Example 4: Display Content Till Specific Line

To display the file’s content at the specific line numbers, the “-5” option is used with the file name:

$ more -5 file.txt

This will display the contents of file.txt with line numbers.

Example 5: Display a Usage Message at the Bottom

To display a message at the bottom of the screen explaining how to use more, follow the below script:

$ more -d file.txt

This will display the contents of file.txt with a message at the bottom of the screen explaining how to use the more command.

That is all from the “more” command.

Conclusion

Linux offers a “more” command to visualize the contents of a file at a time. Using this, users can view the file content starting at a specific line number, visualize multiple files’ content, display content till a specific line, and display a message at the bottom. This guide has explained all possible examples of the “more” command in Linux.

Over 500 Million Views on Our Blogs and YouTube! We’re inviting 10 businesses to partner with us and grow together. Click here to join us! ×