The more utility is suitable for page-by-page viewing of files in the Linux terminal. It owes its name to more, which appears at the bottom of each page. The more linux command is one of the most primitive commands for working with text. Its closest relative, the less command, has a much larger set of options and additional features. Let's take a look at its syntax and examples of its use.
In the Linux terminal emulator, the command is written as follows:
The list of command options:
-d - output information at the end of the page about the keys used to continue, terminate, or receive instructions;
-l - ignore the page break character in the text;
-f - counting the number of logical lines instead of screen lines;
-p - clearing the terminal screen so that the user does not have to scroll before displaying the next portion of text;
-c - eliminating the need for scrolling (like -p) - displaying text starting from the top of the screen and erasing the previous output line by line;
-s - replace several empty lines in a row with one empty line;
-u - deletion of underlining;
-n - displaying the n-th number of lines;
+n - display text starting from the line with the number n;
+/line - search for the specified line in the file and start displaying text from it;
--help - call help;
-v (--version) - display the current version of the utility.
The more command also has its own hotkeys and interactive commands:
h (?) - help (display information about interactive commands only);
SPACE - display the next portion of text (by default, the number of lines depends on the current size of the terminal window);
z - the same as SPACE;
ENTER - display text line by line (command step - one line);
d (^D) - scroll the text by the number of lines corresponding to the terminal size;
q (Q) - exit the utility;
s - move one line forward;
f - move one screen page forward;
b (^B) - go back one screen page;
' - return to the place where the search was started;
= - display the current number of lines;
/pattern - search using regular expressions;
n - search for words and phrases corresponding to the last used regular expression;
!command (:command) - execution of a command in a sub-shell;
v - open the file in the text editor assigned by default, and if none is found, use the console text editor to open the file;
^L - delete everything but the contents of the file from the screen;
:n - move to the next file;
:p - move to the previous file;
:f - display the name of the current file and the number of lines in it;
. - repeat execution of the previous command.
In order to view text from a file, the command is used:
You can also list several file names one by one in the command, separating them with a space. The contents of these files will be output in the same order. Example:
If a file is not in the current directory, you should specify its full address.
Sometimes it is necessary to display not the whole text, but only a part of it. For such cases the options - (minus) and + (plus) are provided, next to which the number of lines is specified. For example, to see the contents of the file starting from line 8, you should add the +8 option to the command, and for the command to display the result consisting of a maximum of 5 lines, you should add the -5 option:
By default, the more Linux command counts as a string exactly the screen line - the number of characters that fit in one row across the width of the window. To perform counting in logical strings (when typing, they are separated by pressing Enter), the -f option is used. Example:
more can work not only with text files - you can redirect output of other commands to it (pipelining). The first is the main command, the second is more with the required options. Commands are necessarily separated by a vertical line. Example:
When a command has output a part of text and is idle waiting for further user actions, you can execute interactive commands. They are needed to control the output.
To find out the number of the current line, you should press the = key, and to view the file in a text editor you should press the v key.
Note that not all commands can be executed if the output of another command is redirected to the utility. Opening a text editor, as well as going back one page (b or ^B) works only when viewing text files.
To get a list of all interactive commands, press the h key.
Apply the discount by inserting the promo code in the special field at checkout: