Linux More Command – Examples + Options

Last updated: March 15, 2022

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.

Prerequisites

  • Any Linux system
  • Basic command line knowledge
  • A good smile to learn

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.

Basic Syntax of more command:

more [options] filename

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.

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 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 bank line

If the file has multiple blank lines use -s option to squeeze multiple blank lines into one bank 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.

Linux more command options

Some of the commonly used more command options:

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
-nView specified number of lines in the window
+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

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