Linux more Command Explained [With Examples]

Written by: Linuxopsys   |   Last updated: July 3, 2023

Normally short text files are viewed using cat command. When it comes to large files cat command shows the last section, and you have to scroll up to read other sections. There is a better way to view files using Linux more command.

In this tutorial, we learn about Linux more command, and how to use it.

What is more command in Linux

Linux more command is used to display text files from the command line. This command is mostly used to display large files. More command helps to view files one screen at a time. It does not support backward scrolling (except for going back one page).

Basic Syntax of more command:

more [options] filename

The following table lists the options for more command:

OptionsDescription
-dAllow to Press 'Space bar' to continue, 'q' to quit, Press 'h' for instructions, instead of sound when an illegal key is pressed
-fLong lines are not wrapped, kept as it is
-pclear the whole screen and then can view the text
-cDisplay by overlapping same area
-sSqueeze multiple blank lines
-uIgnore underlines
-nSearch the string in each file before starting to display it
+nInteger number from where the text to display
+/stringSearch string in each file before starting to display it

Linux more also supports interactive commands those are based on vi. The k in the description means those commands may be preceded by a decimal number.

Interactive commandsDescription
hIf you forgot commands use help to get a summary
<space>Display next k lines of text
dScroll k lines
sSkip forward k lines
bskip backward k screenful of text
:nGo to kth next file
:pGo to kth previous file

How to Use More command

More command is usually used without any options. Type more followed by the filename to view the first page within the available screen size. More command is especially useful for forward navigation.

linux more command

The bottom percentage shows the % of the file that more command has read.

Use the following commands to scroll the page:

  • Press Enter Key to scroll down line by line.
  • Press Space bar to navigate to next page.
  • Press b key to go back one page.
  • Press q key to quit more and return to the command line.

You can also use more command with other commands using the pipe. For example ls -l | more here more commands read the output of ls -l command.

The more command in Unix/Linux does not have a built-in option to directly go to the end of the file. With more, the navigation is primarily done by pressing Spacebar to go forward one page and b to go back one page, and it does not provide a way to skip directly to the end of a file.

The less command performs the same functionality of more command but has extensive enhancements. Mainly less command good at forward and backward navigation.

Linux more command Examples

Here let's check Linux more command capabilities with some examples.

Better user navigation using -d option

The -d option it allows to continue by pressing the Space bar and q to exit from reading. You can see a prompt at the bottom of each page for the same.

Example:

more -d /etc/ssh/ssh_config
output of more command d option

Display First Specified Number of Lines of a file

To display a specified number of lines in a window, type:

more -5 /etc/ssh/ssh_config 
display first N number of lines

Display Text After Specified number of Lines

Use +num option to display text after a specified number of lines of the file.

more +5 /etc/ssh/ssh_config

More will open the file named /etc/ssh/ssh_config at line number 5.

Squeeze multiple blank line

If the file has multiple blank lines use -s option to squeeze multiple blank lines into one blank line.

 more -s /path/to/filename 

Search a string

Use the option +/string to search for the string pattern in the text document.

more +/Proxy /etc/ssh/ssh_config
more command string search

This search for the pattern 'Proxy' in the file named /etc/ssh/ssh_config. Remember the string search is case sensitive.

Conclusion

In this tutorial, we learned about Linux more command with examples. We have gone through some useful more command options which help to view text files. For more information check more manual page or type man more from the command line.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment