How Can We Help?
< All Docs
Print

Explanation of less, more and most command in Linux

Table of Content
less more and most command in Linux

We will explain the less, more, and most commands in Linux in this article. When looking at the contents of a file in Linux, we might find it helpful to use some interactive features. We might need to see statistics about a file we're looking at, mark a line and come back to it later, or look at a file's contents while it's being changed.

Terminal pagers let you look at files line by line or page by page. More, less, and most are three of them that we'll look at. All of them have similar features, like being able to look at multiple files at once, but each has a feature or advantage that makes it stand out and might make us want to use it.

Method of using

we can use these command in Linux by running below commands

# more file1.txt file2.py file3 
# less file1.txt file2.py file3
# most file1.txt file2.py file3

Now, after using and entering into these commands' prompt, you can exit from these by pressing 'Ctrl -c' or q.

You can also use the pipe '|' symbol for the output of another command as an input:

# history | less 

1. more command

more is one of the oldest pagers for terminals in the UNIX world. More used to only scroll down, but now we can use it to scroll up one screen at a time and down either one line or one screen at a time.

# more filename.ext 
Explanation of less, more and most command in Linux
Output of more command

More's status bar shows how much of the file has been read. It shuts down by itself when the file is done, so you don't have to press a button.

1.2 Options of more command

More's status bar shows how much of the file has been read. It shuts down by itself when the file is done, so you don't have to press a button.

  • space – go to the next page in accordance with the terminal’s size
  • b – go back one page
  • enter – scroll down one line
  • = – display the current line number
  • :v – start up the vi text editor at the current line

2. less command

One reason why less was made was so that you could move backward line by line. It has a lot of commands that are similar to the commands in the vi text editor. It also lets you scroll horizontally, watch live, and do other things.

When reading a large file, we may want to mark certain spots with bookmarks so we can go back to them.

We can mark a certain line in less by pressing m and then another character, like X. We can start a new line by pressing m and then another letter, like Y. Then, if we scroll to another part of the file, we can go back to the lines we marked by pressing the apostrophe key (') and the character we used to mark.

In this case, we can switch between our bookmarks by typing 'X and 'Y.

 command in Linux
Output less command

Let's say we want to keep an eye on the changes being made to a log file, but we don't want to keep running less on it. By pressing the Shift+F keys or running the command with the +F flag, we can switch to seeing the changing content of the file.

3. most command

Most of them let us look at several files at once and switch between them. It's very helpful for viewing large data sets because most of them don't wrap lines that have more characters than the terminal page. Instead, it cuts them off and lets you scroll horizontally from column to column.

By giving files as arguments to most, we can show more than one file and switch between them.

# most file1 file2 

By default, while reading a file, the status bar shows the file name, the percentage of the file we've seen so far, the current line number, and our horizontal position, since we can scroll left and right by pressing the left and right keys.

less, more and most command in Linux
most command after pressing colon

If we press:n, we can switch between files. Then, we can change file names with the up and down arrow keys and go to the selected file by pressing enter:

Explanation of less, more and most command in Linux
after pressing n

We might also want to read one file in binary mode and another file in non-binary mode. Most of them let us view files in different ways. For example, while viewing a file, we can switch between options by pressing ":" and "o." Pressing "b" switches between binary mode and text mode.

Summary

If we want a simple pager for a terminal that is easy to find, we would choose more.

But if we want to use the commands in the vi text editor and would rather use a tool with better horizontal and vertical scrolling, less is a good choice.

less and less programmes let you look at more than one file at once. More lets us see them as one file with lines separating them, and less lets us move between them. But both more and less show the same options for all the opened files.

Lastly, most is a good choice if we want to open multiple files with different options or see more information on the status bar while viewing a file. However, installing it in our Linux environment may be necessary.

Table of Contents