How to pause listing long text file with cat in command prompt after 10lines then press any key. for example:

cat myfiles.txt

press enter to continue

6 Answers 6


You can use less or more. Both will work.

The less command is more commonly used and provides more functionality than more.

Using both less or more, you can traverse a file page by page using the space bar, and line by line using the enter key.

There's no need to cat and pipe the file, either. You can just run the command on the file.

E.g. less myfile.txt

  • Does anyone know why these dont work in initrd or when using init=/bin/bash? Less is not found by Ubuntu's initrd, but more and scrolling dont work making seeing anything longer than a page seem impossible?
    – alchemy
    Jan 6, 2022 at 22:17

more and less are pagers which deal with paging through text on the console. less is more functional, but more is closer to what you want. If you specify the -d option more will show how to move to the next page, and you can use -num to specify the number of lines to show at a time (instead of auto detecting the screen size).

% more -d -5 myfiles.txt
--More--(4%)[Press space to continue, 'q' to quit.]

You should try cat myfiles.txt | more

  • 1
    less is more common these days
    – jdd
    Jul 31, 2012 at 4:52
  • You could also try most instead.
    – scai
    Jul 31, 2012 at 5:38
  • 4
    or just more myfiles.txt without the UUOC.
    – cas
    Jul 31, 2012 at 7:51

You can use scroll-lock, although it might not be very useful if data rate is high. Ctrl-s to block and Ctrl-q to unblock.


Alternative, to scroll back the buffer, while inside a tmux session:

Type CTRL + b + PgUp/PgDown

How to increase scrollback buffer size in tmux?


There is an alternative to using less or more in case those commands are not available. (like my setup) This does not achieve pause and continue but you can read section by section.

One can use head and/or tail

head -n 10 myfiles.txt

The above command will print the first 10 lines of the file


tail -n 10 myfiles.txt

The above command will print the last 10 lines of the file.

You can combine both commands to read the file section by section E.g.

head -n 10 myfiles.txt // Prints first 10 lines
head -n 20 myfiles.txt | tail -n 10 // Prints lines 10-20 
head -n 30 myfiles.txt | tail -n 10 // prints lines 20 to 30
  • 2
    This does not seem to answer the question as the issue is to pause the output every 10 lines. Also note that combining head and tail to read the same file multiple times for the purpose of reading every section of 10 lines would be incredibly cumbersome as you would have to update the arguments to both utilities every time.
    – Kusalananda
    Mar 2, 2023 at 7:04
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 2, 2023 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .