{"id":3198,"date":"2018-03-26T18:01:09","date_gmt":"2018-03-26T14:01:09","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-more-command\/"},"modified":"2018-03-26T18:01:09","modified_gmt":"2018-03-26T14:01:09","slug":"linux-more-command-tutorial-for-beginners-5-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-more-command-tutorial-for-beginners-5-examples\/","title":{"rendered":"Linux more Command Tutorial for Beginners (5 Examples)"},"content":{"rendered":"<p>Sometimes, while working on the command line, you&#8217;ll see outputs produced by commands in certain cases are so large that they don&#8217;t fit into the screen area, and hence, you get to see only the last part of the output (as the initial part scrolls past the screen). Thankfully, there are\u00a0utilities that are specifically designed to help you in such cases, and one of them is <strong>more<\/strong>.<\/p>\n<p>In this tutorial, we will discuss the basics of <em>more<\/em> using some easy to understand examples. Please note that all examples in this article have been tested on an Ubuntu 16.04 LTS system.<\/p>\n<h2 id=\"linux-more-command\">Linux more command<\/h2>\n<p>The more command helps you navigate outputs from commands in a user-friendly way. Following is the tool&#8217;s syntax:<\/p>\n<p class=\"command\">more [options] file&#8230;<\/p>\n<p>And here&#8217;s how the man page defines it:<\/p>\n<pre readability=\"7\"> more - file perusal filter for crt viewing<p>more is a filter for paging through text one screenful at a time.\u00a0 This<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 version is especially primitive.\u00a0 Users\u00a0 should\u00a0 realize\u00a0 that\u00a0 less(1)<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 provides more(1) emulation plus extensive enhancements.<\/p><\/pre>\n<p>Following are some Q&amp;A-styled examples that will give you a good idea on how more works.<\/p>\n<h2 id=\"q-how-to-use-more-command\">Q1. How to use more command?<\/h2>\n<p>Basic usage is very easy. Let&#8217;s say you are trying to &#8216;<a href=\"https:\/\/www.howtoforge.com\/linux-cat-command\/\" target=\"_blank\" rel=\"noopener\">cat<\/a>&#8216; a file, and it&#8217;s too long\/large to be displayed on your screen, then you can use the <em>more<\/em> command in the following way:<\/p>\n<p class=\"command\">more [filename]<\/p>\n<p><a class=\"fancybox\" id=\"img-more-basic\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/more-basic.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/03\/linux-more-command-tutorial-for-beginners-5-examples.png\" alt=\"How to use more command\" width=\"500\" height=\"472\" title=\"\"><\/a><\/p>\n<p>Now, to scroll the display up one line at a time, press enter. If you want to scroll a screenful in one go, use the space bar key. Backwards scrolling can be achieved by pressing &#8216;b&#8217;. Oh, and yes, you can also search stuff by pressing &#8216;\/&#8217; and entering the search keyword (just like you do in man pages).<\/p>\n<p>You can also combine the more command with other command line tools, something which can be done using pipes. For example:<\/p>\n<p class=\"command\">dmesg | more<\/p>\n<p>In the above command, the display of the output produced by dmesg will be handled by more. So you can easily scroll up, down, and even perform search operations.<\/p>\n<p>Here&#8217;s another example:<\/p>\n<p class=\"command\">ls -lart | grep *.txt | more<\/p>\n<h2 id=\"q-how-to-make-more-prompt-useful-information\">Q3. How to make more prompt useful information?<\/h2>\n<p>Use the <strong>-d<\/strong> command line option for this. This will enable <em>more<\/em> to prompt with &#8220;[Press space to continue, &#8216;q&#8217; to quit.]&#8221;, and display &#8220;[Press &#8216;h&#8217; for instructions.]&#8221; whenever an illegal key is pressed.<\/p>\n<p>For example:<\/p>\n<p class=\"command\">more -d [filename]<\/p>\n<p><a class=\"fancybox\" id=\"img-more-d\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/more-d.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/03\/linux-more-command-tutorial-for-beginners-5-examples-1.png\" alt=\"How to make more prompt useful information\" width=\"500\" height=\"121\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-make-more-ignore-multiple-blank-lines\">Q4. How to make more ignore multiple blank lines?<\/h2>\n<p>If you want, you can even force the more command to squeeze multiple blank lines into one. This can be done using the <strong>-s<\/strong> command line option.<\/p>\n<p class=\"command\">more -s [filename]<\/p>\n<p>For example, a file like this:<\/p>\n<p><a class=\"fancybox\" id=\"img-more-file-with-spaces\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/more-file-with-spaces.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/03\/linux-more-command-tutorial-for-beginners-5-examples-2.png\" alt=\"How to make more ignore multiple blank lines\" width=\"418\" height=\"550\" title=\"\"><\/a><\/p>\n<p>was displayed by more in the following way when the -s option was used:<\/p>\n<p><a class=\"fancybox\" id=\"img-more-s-option\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/more-s-option.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/03\/linux-more-command-tutorial-for-beginners-5-examples-3.png\" alt=\"Blank lines removed from output\" width=\"498\" height=\"323\" title=\"\"><\/a><\/p>\n<p>So you can see multiple empty lines got squeezed into a single one each time the more command encountered them.<\/p>\n<h2 id=\"q-how-to-reduce-the-number-of-lines-more-uses\">Q5. How to reduce the number of lines more uses?<\/h2>\n<p>By default, more uses the complete screen to display output. However, you can even customize this in terms of number of lines used by the tool. This can be done by explicitly specifying the number of lines you want more to use.<\/p>\n<p>For example, if we want more to display the output using 10 lines at a time, then we can do that in the following way:<\/p>\n<p class=\"command\">more -10 [filename]<\/p>\n<p><a class=\"fancybox\" id=\"img-more-number\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/more-number.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/03\/linux-more-command-tutorial-for-beginners-5-examples-4.png\" alt=\"How to reduce the number of lines more uses\" width=\"498\" height=\"211\" title=\"\"><\/a><\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>As you&#8217;ll likely agree, the more command is a useful little utility that can be of great help in specific scenarios. We&#8217;ve discussed the basic operation here. Once you&#8217;re done with it, you can learn more about the tool by heading to its <a href=\"https:\/\/linux.die.net\/man\/1\/more\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, while working on the command line, you&#8217;ll see outputs produced by commands in certain cases are so large that they don&#8217;t fit into the screen area, and hence, you get to see only the last part of the output (as the initial part scrolls past the screen). Thankfully, there are\u00a0utilities that are specifically designed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-3198","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=3198"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3198\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=3198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=3198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=3198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}