1

It is given in the man page of more that f is used to skip forward k screenful of text(default to 1).I saved a very long file using cat and used more to show it on the screen page by page but when i pressed f on the first page itself, it is not navigating forward but it shows ... skipping 29 lines and then the file closes and the prompt returns.When i try to navigate with spacebar it is working properly as expected. As file length is sufficiently long,it should navigate forward by skipping 1 page each time. Why it is showing such a different behviour?

enter image description here

1

Try this experiment:

  • Open a terminal with 25 rows.
  • Run seq 1 1 100 > test_text.
  • Run more test_text.
  • Look at the line before last on your screen. It'd say 24.
  • Press f to skip a page.
  • Look at the first line on screen. It'd say 49.

f skips a page of text. So you saw the first "page" of the file, you pressed f, and you saw the third page.

At this point, if you press f again, you'll see ... skipping 24 lines and the last 4 lines of the file. more'll exit because there are not enough lines to show a fifth page.

Try again using space instead. space does not skip pages. You'll see all the pages.

Edit

This answer refers to more version 5.19 (Berkeley 6/29/88), which is currently in use in the Linux community (see man more). As @Kusalananda reports, the result of the "experiment" may vary on different versions/unices.

Difference between a line and a row of text on a terminal

Often these two definitions are interchangeable. In this case, it is important to distinguish them.

  • A line is a sequence of characters in a text file that ends with a newline (the \n character). wc -l command counts the number of lines in a file. The length of a line can be any number between zero and infinite.
  • A row of text (on a terminal) is a sequence of characters displayed on a terminal. It has the fixed length of the width of the terminal.

My first "experiment" was too simple, all the lines were (quite for sure) shorter than rows.

In your file, probably, the lines are way longer than rows. To display them, more will arrange each line on multiple rows.

Let's try a new experiment:

  • Create a file example with this content:

    006 XX\n010 XXYYYY\n015 XXYYYYZZZZZ\n
    

    This is a 3 line file. The length of each line is, in the order: 6, 10 and 15 characters. Do not forget to count the space after the number.

  • Run wc -l example. 3 is the result.

  • On a 8 columns terminal, you should see something like

    006 XX  
    010 XXYY
    YY      
    015 XXYY
    YYZZZZZ 
    

    The first row is 8 character lenght: 006 + a space + XX + 2 spaces.

    The second row is 8 character lenght: 010 + a space + XXYY.

    The 3rd row is 8 character lenght: YY + 8 spaces.

    Etc etc.

Your 3 lines of text are now 5 rows of text.

The manual page of more says:

 f         Skip forward k screenfuls of text.  Defaults to 1.

This means that more will skip so many line of text to fill all the rows of the terminal.

  • 1
    Hmmm... it's unfortunate that such a basic command is different on different Unices. On my OpenBSD system, f and Space (and ^F) are exactly equivalent according to the manual. I see now that this is different on Linux, which is why I was confused by the question at first. – Kusalananda Jan 22 at 18:27
  • @andcoz i am clearly getting what you are trying to say but my doubt still remains.The file i have used with the more has almost 5 pages on a 25 row terminal(i checked it by using spacebar) but when i press f at the first page it don't show the third page as expected. It shows ... skipping 24 lines and then the more exits and the prompt returns.In my case i am having five page file even then the more is not showing the third page .that's my doubt why it is showing such a behaviour? – Noshiii Jan 22 at 21:07
  • Is your MORE environment variable set to some value? Is more an alias? – andcoz Jan 23 at 9:09
  • 1
    Can you count the lines in the file using wc -l filename? Is it possible that your file have less than 50 lines but that some line are longer than the width of terminal window? – andcoz Jan 23 at 9:12
  • I checked echo $MORE ,it is showing an empty line and more is not an alias in my case.when i used wc -l filename it is showing 25 lines but how is it possible ? The article from where i copied the text has around 46 lines .Also i used cat -n filename to check number of lines and it is taking whole paragraphs as a single line and it is also showing 25 lines in total . How do i check whether my lines are longer than the width of the terminal window, as long lines fit themselves according to the size of terminal. – Noshiii Jan 23 at 11:57
1

but it shows ...skipping 29 lines and then the file closes and the prompt returns

That happens when you press f and you reach the end of the document.

For example: You have a file of 40 lines, you do more myfileof60lines.txt, it displays the 29 first lines, then you press f, so it will skip the 29 next lines, but before that, it reaches the end of the document. So you end up with seeing ...skipping 29 lines, and the normal behavior of more when it reaches the end of the document, which is a return to prompt.

  • can you see my comments in the @andcoz's answer, i am having little bit trouble to understand – Noshiii Jan 23 at 12:00
  • Out of the matter, you can use the command less. My favourite. – jayooin Jan 23 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.