Home Command line utilities The Difference Between more, less And most Commands
difference between more, less and most commands

The Difference Between more, less And most Commands

By sk
1591 Views

If you're a newbie Linux user, you might be confused with these three command like utilities, namely more, less and most. No problem! In this brief guide, I will explain the differences between these three commands, with some examples in Linux. To be precise, they are more or less same with slight differences. All these commands comes preinstalled in most Linux distributions.

First, we will discuss about 'more' command.

The 'more' program

The 'more' is an old and basic terminal pager or paging program that is used to open a given file for interactive reading. If the content of the file is too large to fit in one screen, it displays the contents page by page. You can scroll through the contents of the file by pressing ENTER or SPACE BAR keys. But one limitation is you can scroll in forward direction only, not backwards. That means, you can scroll down, but can't go up.

more command demo

The 'more' command demo

Update:

A fellow Linux user has pointed out that more command do allow backward scrolling. The original version allowed only the forward scrolling. However, the newer implementations allows limited backward movement. To scroll backwards, just press b. The only limitation is that it doesn’t work for pipes (ls|more for example).

To quit, press q.

more command examples:

Open a file, for example ostechnix.txt, for interactive reading:

$ more ostechnix.txt

To search for a string, type the search query after the forward slash (/) like below:

/linux

To go to then next matching string, press 'n'.

To open the file start at line number 10, simply type:

$ more +10 file

The above command show the contents of ostechnix.txt starting from 10th line.

If you want the 'more' utility to prompt you to continue reading file by pressing the space bar key, just use -d flag:

$ more -d ostechnix.txt

more 1

As you see in the above screenshot, the more command prompts you to press SPACE to continue.

To view the summary of all options and keybindings in the help section, press h.

For more details about 'more' command, refer man pages.

$ man more

The 'less' program

The 'less' command is also used to open a given file for interactive reading, allowing scrolling and search. If the content of the file is too large, it pages the output and so you can scroll page by page. It allows scrolling on both directions. Meaning - you can scroll up and down through a file.

less command demo

The 'less' command demo

So, feature-wise, 'less' has more advantages than 'more' command. Here are some notable advantages of 'less' command:

  • Allows forward and backward scrolling,
  • Search in forward and backward directions,
  • Go to the end and start of the file immediately,
  • Open the given file in an editor.

less command examples:

Open a file:

$ less ostechnix.txt

Press SPACE BAR or ENTER key to go down and press 'b' to go up.

To perform a forward search, type search query after the forward slash (/) like below:

/linux

To go to then next matching string, press 'n'. To go back to the previous matching string, press N (shift+n).

To perform a backward search, type search query after the question mark (?) like below:

?linux

Press n/N to go to next/previous match.

To open the currently opened file in an editor, press v. It will open your file in your default text editor. You can now edit, remove, rename the text in the file.

To view the summary of less commands, options, keybindings, press h.

To quit, press q.

For more details about 'less' command, refer the man pages.

$ man less

The 'most' program

The 'most' terminal pager has more features than 'more' and 'less' programs. Unlike the previous utilities, the 'most' command can able to open more than one file at a time. You can easily switch between the opened files, edit the current file, jump to the Nth line in the opened file, split the current window in half, lock and scroll windows together and so on. By default, it won't wrap the long lines, but truncates them and provides a left/right scrolling option.

most command examples:

Open a single file:

$ most ostechnix1.txt
most command

View a file using most command

To edit the current file, press e.

To perform a forward search, press / or S or f and type the search query. Press n to find the next matching string in the current direction.

To perform a backward search, press ? and type the search query. Similarly, press n to find the next matching string in the current direction.

Open multiple files at once:

$ most ostechnix1.txt ostechnix2.txt ostechnix3.txt

If you have opened multiple files, you can switch to next file by typing :n. Use UP/DOWN arrow keys to select next file and hit ENTER key to view the chosen file.

most 2

Switch between files using 'most' program

To open a file at the first occurrence of given string, for example linux:

$ most file +/linux

To view the help section, press h at any time.

List of all keybindings:

Navigation:

  • SPACE, D - Scroll down one screen.
  • DELETE, U - Scroll Up one screen.
  • DOWN arrow - Move Down one line.
  • UP arrow - Move Up one line.
  • T - Goto Top of File.
  • B - Goto Bottom of file.
  • > , TAB - Scroll Window right.
  • < - Scroll Window left.
  • RIGHT arrow - Scroll Window left by 1 column.
  • LEFT arrow - Scroll Window right by 1 column.
  • J, G - Goto nth line. For example, to jump to the 10th line, simply type "100j" (without quotes).
  • % - Goto percent.

Window Commands:

  • Ctrl-X 2, Ctrl-W 2 - Split window.
  • Ctrl-X 1, Ctrl-W 1 - Make only one window.
  • O, Ctrl-X O - Move to other window.
  • Ctrl-X 0 (zero) - Delete Window.

Search through files:

  • S, f, / - Search forward.
  • ? - Search Backward.
  • N - Find next match in current search direction.

Exit:

  • q - Quit MOST program. All opened files will be closed.
  • :N, :n - Quit this file and view next (Use UP/DOWN arrow keys to select next file).

More details about 'most' command can be found in the man pages.

$ man most

TL;DR

more - An old, very basic paging program. Allows only forward navigation and limited backward navigation.

less - It has more features than 'more' utility. Allows both forward and backward navigation and search functionalities. It starts faster than text editors like vi when you open large text files.

most - It has all features of above two programs including additional features, like opening multiple files at a time, locking and scrolling all windows together, splitting the windows and more.

And, that's all for now. Hope you got the basic idea about these three paging programs. I've covered only the basics. You can learn more advanced options and functionalities of these programs by looking into the respective program's man pages.

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

7 comments

Robert Spanjaard November 10, 2018 - 1:37 am

Did you even bother to press “h” in more yourself? Did YOU read the man page before writing this article? In more you can scroll back too by pressing b when reading a file. The only limitation is that it doesn’t work for pipes (ls|more for example).

Also keep in mind that more handles color codes correctly, less does not.

Reply
sk November 10, 2018 - 12:14 pm

You’re right. I updated the guide with your inputs. Thank you.

Reply
AAA November 7, 2019 - 8:55 am

Nice summary, IMO.

Add syntax highlighting
https://gist.github.com/textarcana/4611277

Have a look at bat as well…
https://github.com/sharkdp/bat

Reply
Gérard Talbot November 8, 2019 - 12:14 am

You wrote:
To search for a string, type the search query after the forward slash (/) like below:

/linux

But according to the man more documentation, it should be +/linux, like this:

$ more +/linux ostechnix.txt

Reply
sk November 8, 2019 - 12:54 pm

Yes, you’re right. But If the file is already opened with “more” program, you need not to type “+/linux”. Just type: /linux.

Reply
Gérard Talbot November 8, 2019 - 12:16 am

I can not see the “+” in the more command I wrote … this must be caused by your comment form.

Reply
Vernon Tillerson November 8, 2019 - 10:15 am

If you save output which has colored text (ANSI VT escape sequences) only “less” can display these as colored text rather than just showing the raw characters, when the -R flag is invoked vis less -R colored_output.log

most makes a good pager for manual pages.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More