Skip to content

more command in Linux

The more command in Linux allows users to view the contents of large files page by page, facilitating easy navigation and search within the file. By displaying one screen of text at a time, more enables users to read through lengthy documents without overwhelming the terminal. With simple keyboard commands, users can move forward, backward, search for specific text, and quit the viewing process. This command provides a straightforward and efficient way to handle extensive text files in the Linux environment.

more Syntax:

Terminal window
more [option] [file]

Linux more Options:

OptionDescription
-dDisplay more prompt
-fCount logical pages
-lIgnore form feeds
-pDo not scroll screen
-sSqueeze multiple blank lines
-uSuppress underlining

more Parameters:

ParameterDescription
fileThe file to be viewed

How to use more command:

Display contents of a file using more

Terminal window
more filename.txt

This command displays the contents of the “filename.txt” file page by page.

Show line numbers when viewing a file

Terminal window
more -N filename.txt

The “-N” option displays line numbers when viewing the “filename.txt” file.

View content of multiple files in sequence

Terminal window
more file1.txt file2.txt

Displays the content of “file1.txt” followed by the content of “file2.txt” sequentially.

Search within a file while using more

Terminal window
more filename.txt
/pattern

The “slash” followed by a search pattern allows you to search within the “filename.txt” while using more.

Scroll up one line at a time

Terminal window
more -d filename.txt

Use the “-d” option to scroll up one line at a time when viewing the content of “filename.txt”.

Jump to a specific line number

Terminal window
more +10 filename.txt

Jumps directly to line 10 when viewing the content of “filename.txt”.

Skip over the first n lines

Terminal window
more +5 filename.txt

Skips the first 5 lines and starts displaying the content of “filename.txt” from the 6th line onwards.

Display help information for more command

Terminal window
more --help

Shows the help information for the more command, including available options and usage details.

How do I use more in Linux?

To use the more command in Linux, execute the following command:

Terminal window
more --option <value>

What are some common options for the more command?

Some common options for the more command in Linux include:

Terminal window
more -d file.txt

How can I scroll back while using more?

To scroll back while using the more command in Linux, press the b key.

How do I search for text within the more command?

You can search for text within the more command by typing a forward slash (/) followed by the text you want to search for. Press Enter to start the search and n to find the next occurrence.

How do I display line numbers in more?

To display line numbers while using the more command in Linux, you can use the following command:

Terminal window
more -n file.txt

How can I navigate to the beginning or end of a file with more?

To navigate to the beginning of a file with more, use the g command. To navigate to the end of a file, use the Shift+g command.

How do I use the more command to view multiple files?

You can use the more command to view multiple files by providing the file names as arguments. For example:

Terminal window
more file1.txt file2.txt

Can I use the more command with pipes in Linux?

Yes, you can use the more command with pipes in Linux to view the output of a command. For example:

Terminal window
ls -l | more

How do I exit the more command with a specific status?

To exit the more command with a specific status, you can use the following key combination:

Terminal window
Ctrl + C

Applications of the more command

  • Viewing text files one screen at a time
  • Navigating through large files
  • Searching for specific strings within a file
  • Skipping through large sections of text
  • Pausing and resuming output in the terminal