How to pause listing long text file with cat in command prompt after 10lines then press any key. for example:
press enter to continue
less command is more commonly used and provides more functionality than
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.
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
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.]
Alternative, to scroll back the buffer, while inside a tmux session:
There is an alternative to using
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 -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