more command is used to view the text files in the command prompt, displaying one screen at a time in case the file is large (For example log files). The more command also allows the user do scroll up and down through the page. The syntax along with options and command is as follows. Another application of more is to use it with some other command after a pipe. When output is large, we can use more command to see output one by one.
more [-options] [-num] [+/pattern] [+linenum] [file_name]
[-options]: any option that you want to use in order to change the way the file is displayed.
Choose any one from the following-:
(-d, -l, -f, -p, -c, -s, -u)
[-num]: type the number of lines that you want to display per screen.
[+/pattern]: replace pattern with any string that you want to find in the text file.
[+linenum]: use the line number from where you want to start displaying the text content.
[file_name]: name of the file containing the text that you want to display on the screen.
while viewing the text file use these controls :
Enter key: to scroll down line by line.
Space bar: To go to the next page.
b key: To go to back one page.
options used with more command
-d :use this command in order to help the user to navigate. It displays “[Press space to continue, ‘q’ to quit.]” and displays “[Press ‘h’ for instructions.]” when wrong key is pressed.
Input : more -d sample.txt Output :
-f :this command does not wrap the long lines and displays them as such.
Input : more -f sample.txt Output :
-p :this command clears the screen and then displays the text.
Input : more -p sample.txt Output :
-c :this command is used to display the pages on the same area by overlapping the previous displayed text.
Input : more -c sample.txt Output :
-s :this command squeezes multiple blank lines into one single blank line.
Input : more -s sample.txt Output :
-u :this command omits the underlines.
Input : more -u sample.txt
+/pattern :this command is used to search the the string inside your text document.You can view all the instances by navigating through the result.
Input : more +/reset sample.txt Output :
+num :this command displays the text after the specified number of lines of the document.
Input : more +30 sample.txt Output :
Using more to read long outputs
We use more command after a pipe to see long outputs. For example, seeing log files, etc.
cat a.txt | more
- cd command in Linux with Examples
- until command in Linux with Examples
- gcc command in Linux with examples
- tee command in Linux with examples
- top command in Linux with Examples
- rm command in Linux with examples
- rev command in Linux with Examples
- tty command in Linux with examples
- help Command in Linux with examples
- fg command in Linux with examples
- ssh command in Linux with Examples
- wc command in Linux with examples
- tar command in Linux with examples
- df Command in Linux with examples
- gs command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.