more command in Linux with examples

Let’s learn about the more command in Linux with examples and options, so more command is mainly used to view the content of the logs files and the bigger files.

By using the more command we can scroll or content from one page to another.

How to view the content of a Single File using more command in Linux?

So, to view the content of a particular file just simply use less file_name.

Command:
#more system_log

How to view the content of a Multiple File using more command in Linux?

Command:
#more first_file second_file third_file

So, as I have used the three files first_file, second_file, and third_file to view the content.

But this will show the content of the first_file after I hit a SPACE key it will show the content of the next file.

So, to see the content of the next file you have to use SPACE key.

How to view move between File using more command?

So, now we will look how we can use SPACE, b, -c, and p option.

First we will use a SPACE key option to display the new lines.

So, with the SPACE you can also use z key to scroll down by one page.

If we have to move in the backwards direction by one page then will use b key.

So, -c option instead of scrolling the next content, it will clear the screen and then display the new content.

Command:
#more -c more_example

Now, let’s have a look on -p option so instead of scrolling the next content it will shift on the upper side.

Command:
#more -p more_example
How to display the User message of File using more command?

So, -d option is used to prompt with “[Press space to continue, ‘q’ to quit.]” and display “[Press ‘h’ for instructions.]”

Also, -d option will ring the bell when we will press any wrong key.

Command:
#more -d more_example

How to Open a File on a Particular line using more command?

So, we will use +(plus) sign and the line number on which we have to open the file

Command:
#more +20 more_example

So in the above command, we have used +20 means after skipping 20 lines it will display the content.

How to set a screen size using more command?

To set the size of the screen we will use -(minus) sign with the screen size set as a number of lines.

Command:
#more -12 more_example

In the above example, we have used -12 means it will make one page of 12 lines and display the output.

So, after hitting SPACE key, you can see the next page of 12 lines only and when you will use b key it displays the previous 12 lines.

How to search a Pattern using more command?

Suppose we have to search the word “Hostname”, then we will +(plus) sign and then use the word, means it will be like +/Hostname.

Command:
#more +/Hostname more_example

So, when it will find the word Hostname after that it will display the whole content

If you have to search the word like “Network Manager” then your command will be like this.

Command:
#more +/"Network Manager" more_example

How to edit a file using more command?

So, if you have to edit the file then just press the “key v”, it will open a vi editor by default and then we can update the content and save and quit the file by using :wq.

Cheat Sheet of a more command.
How to view the content of a Single File using more command in Linux?

Syntax:
#more [file_name]

Example:
#more first_file
How to view the content of a Multiple File using more command in Linux?

Syntax:
#more [file_name1] [file_name2] [file_name3]

Example:
#more first_file second_file third_file
How to view move between File using more command?

To display the new lines or content or to move forward by one page
use SPACE key

To move on backward Direction by one page
use b key
How to display the User message of File using more command?

Syntax:
#more -d [file]

Example:
#more -d first_file
How to Open a File on a Particular line using more command?

Syntax:
#more +number [file]

Example:
#more +20 more_example
How to set a screen size using more command?

Syntax:
#more -number [file]

Example:
#more -12 more_example
How to search a Pattern using more command?

Syntax:
#more +/pattern [file]

Example:
#more +/Hostname more_example
#more +/"Network Manager" more_example
How to edit a file using more command?

press v key to open the Editor.
By default it will open a vi Editor. 

[wp_quiz id=”2823″]

Thanks to reading the post, If you want to learn about the less command refer to the link.

Give your valuable time