more command

The more command is used to display a small portion of a file at a time. If you wish to see the next entire page, simply press the spacebar. Pressing the enter key will simply display the next line of the file. This allows you to browse a file as you desire. It also takes a numeric argument to allow you to display only a certain number of lines initially, or to even begin at a specific line number.

Command: more
Synopsis: more [OPTION] [-num] [+/ pattern] [+ linenum] [file …]

Options:

OptionDescription
-cDo not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.
-dMore will prompt the user with the message “[Press space to continue, ‘q’ to quit.]” and will display “[Press ‘h’ for instructions.]” instead of ringing the bell when an illegal key is pressed.
-fCauses more to count logical, rather than screen lines (i.e., long lines are not folded).
-lMore usually treats ^L (form feed) as a special character, and will pause after any line that contains a form feed. The -l option will prevent this behavior.
-numThis option specifies an integer which is the screen size (in lines). For example, if you want to use the more command and only see only 5 lines, you would use more -5 test.txt.
-pDo not scroll. Instead, clear the whole screen and then display the text.
-sSqueeze multiple blank lines into one.
-uSuppress underlining.
+/The +/ option specifies a string that will be searched for before each file is displayed.
+numStart at line number num.

Examples

Base Command

more – In this example, we use the base more command on a file named test.txt. Note at the bottom it tells how much of the file is viewable. In this case, 11%. Pressing the Enter key will reveal the next line in the file.

 # more test.txt Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi convallis vehicula nisi. Cras consequat consectetur lectus in cursus. Ut vulputate interdum arcu, imperdiet sodales nisl adipiscing vitae. Quisque blandit urna eu neque consectetur, sit amet scelerisque est dapibus. Donec ut euismod arcu. Vivamus sed urna ut eros blandit scelerisque et laoreet magna. Sed vestibulum mauris quis dolor venenatis sagittis. Cras hendrerit cursus turpis vitae volutpat. Donec adipiscing sagittis enim nec lacinia. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque aliquam purus id facilisis lacinia. --More--(11%) 

Command with directions

more -d – You can think of -d as the ‘direction’ switch. It prints directions at the bottom of the print. It also prints a help message if the user presses an illegal key. Below we first demonstrate the directions.

 # more -d test.txt Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi convallis vehicula nisi. Cras consequat consectetur lectus in cursus. Ut vulputate interdum arcu, imperdiet sodales nisl adipiscing vitae. Quisque blandit urna eu neque consectetur, sit amet scelerisque est dapibus. Donec ut euismod arcu. --More--(5%)[Press space to continue, 'q' to quit.] 

And if the user tries to use an improper command: # more -d test.txt Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi convallis vehicula nisi. Cras consequat consectetur lectus in cursus. Ut vulputate interdum arcu, imperdiet sodales nisl adipiscing vitae. Quisque blandit urna eu neque consectetur, sit amet scelerisque est dapibus. Donec ut euismod arcu. [Press ‘h’ for instructions.]

Display certain number of lines

more -num – This option allows you to control the number of lines displayed on the screen. In this example, we only want to show 5 lines on the screen.

 # more -5 test.txt Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi convallis vehicula nisi. Cras consequat consectetur lectus in cursus. Ut vulputate interdum arcu, imperdiet sodales nisl adipiscing vitae. Quisque blandit urna eu neque consectetur, sit amet scelerisque est dapibus. Donec ut euismod arcu. --More--(1%) 

String Search

more +/ – This command searches for a string before printing that information on the screen. Below we search for the string ‘Mauris’. Note that it added a prefix ‘…skipping’ at the top before beginning the printout.

 # more +/'Mauris' test.txt ...skipping Nunc quis egestas quam.  Mauris ac viverra leo. Cras vehicula magna dolor, sed pharetra tortor condimentum et. Nullam ante dui, gravida in ante eget, auctor convallis mauris. Aenean in blandit libero. Nunc suscipit ultrices odio quis tristique. Proin feugiat turpis elit, et semper turpis pretium sit amet. Praesent ultrices, dui consequat commodo ultricies, velit enim pulvinar libero, posuere consectetur turpis quam vel est. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam cursus diam nunc, nec porttitor elit gravida eu. Donec in neque sapien. Suspendisse porta odio id fermentum placerat. Vivamus aliquam libero id purus bibendum hendrerit. Vivamus molestie eleifend lacus in luctus. Donec vitae lectus eget ligula cursus dapibus. Mauris sollicitudin turpis non mi mattis sodales. Pellentesque vel justo est. --More--(13%) 

Start on specific line number

more +num – By using the +num otpion (where num is an actual number), the more command will begin at that line number. In this example, we begin at line 5.

 # more +/'Mauris' test.txt Donec ut euismod arcu. Vivamus sed urna ut eros blandit scelerisque et laoreet magna. Sed vestibulum mauris quis dolor venenatis sagittis. Cras hendrerit cursus turpis vitae volutpat. Donec adipiscing sagittis enim nec lacinia. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque aliquam purus id facilisis lacinia. Sed id rhoncus augue, convallis imperdiet sem. Nunc quis egestas quam. --More--(12%) 

Was this article helpful? Join the conversation!