How to use more command in Linux with Example

Which command do you use to read files on the terminal? isn’t cat command? “Yes,” I know cat is first preference to read file nothing is wrong to use cat command I use too.

But cat command has some limitations, What limitations? I’ll give you a scenario to understand more precisely. Have you ever tried to read the log from /var/log or any content that has many texts using a cat?

You have noticed it’s read a complete file, and this makes it quite challenging to find a specific line of text using the navigation button. And I’m tired of reading content using cat and finding an alternative way which is more convenient to use?

In this article, you will see how to read files using more commands with a few arguments or options with examples. Before heading, you should know what more command is?

What is more command?

A more command is used to print textfile content on a screen, and It simply displays the amount of text visible to your screen on one page at a time in your terminal.

Apart from this, more commands give you several options to navigate through the file, which make it much easier to read the content.

Usecase

To read a file content, pass the following command:

$ more [FILE-NAME]

more command understands your affection for cat command, that’s a reason you have the choice to use cat and more command simultaneously using [|] pipe.

$ cat [FILE-NAME] | more

5 Funny Linux commands, Literally, we can do?

Screen Navigation

Finally, we reach a point from where we learn how to navigate throughout a file content. Usually, we use navigation keys to navigate, but this will not work at all.

To go down or forward in your open output, you can use multiple options Space bar or Enter key or d or Ctrl – D.

  • Space bar or z: Jump to next page
  • Enter key: Move down line by line
  • d or Ctrl + D: Scroll down by default 11 number, default value change according to terminal size
  • q or Q: To exit

To go up or back one page in your open output, you can use b or Ctrl – B.

Cautious:- Do not use Ctrl + D when connected to a remote system. It might end the current session.

Search Navigation

This option will be a life savior when you know what you are looking for from a text file. It will save your time to scroll much.

To use this, you can use / and type the string or pattern you want to search.

Syntax

/[STRING-PATTERN]

I have STDOUT tar manual to a text file in the below image, and I need to find GNU using interactive options.

$ more text_dump
/GNU
Search using / options

We have different approaches to perform the same task using +/ with more command. To explain you better check the below example

Syntax

$ more +/pattern or string [FILE-NAME]

Command

$ more +/"tar -A" text_dump

Output with Line Number

If you want to print out content that lies on number 50, that is also possible using +number or -number.

To print content store at line number 50, pass the below command:

$ more +50 text_dump.txt
or
$ cat --number text_dump | more +50 
Print content from top using +number

You should notice +number will print content starting from the beginning.

We have another option is -number which will display text content in reverse order, To do pass the below command:

$ more -50 text_dump.txt
or
$ cat --number text_dump | more -50
Print content in reverse order using -number

Wrapping-up

There is much to know about more commands. If you’re eager to know more, go to the Wikipedia page. In interactive mode, you can press ? or h for more options to learn.

We have noticed more command also has a limitation which can minimize using less command.

Make sure to read this:- Less Command in Linux with Examples

If you want to say Hi to me or want to suggest something feel free to contact me.

For short and simple pocket guide follow us on Instagram.

Leave a Reply