How to pause listing long text file with cat in command prompt after 10lines then press any key. for example:
cat myfiles.txt
bla
bla
bla
bla
bla
bla
.
.
.
bla
press enter to continue
asked Jul 31, 2012 at 3:46
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
answered Jul 31, 2012 at 4:53
tacotuesdaytacotuesday
4843 silver badges4 bronze badges
1
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
bla
bla
bla
bla
bla
--More--[4%][Press space to continue, 'q' to quit.]
answered Jul 31, 2012 at 5:40
mgorvenmgorven
2,21218 silver badges19 bronze badges
You should try cat myfiles.txt | more
answered Jul 31, 2012 at 4:00
Chris SChris S
1,3249 silver badges12 bronze badges
3
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.
answered Jul 31, 2012 at 16:49
ThorThor
16.4k3 gold badges51 silver badges68 bronze badges
- SS64
- CMD
- How-to
Display output one screen at a time. MORE can be used to run any executable command [or batch file] and pause the screen output one screen at a time. MORE can also be used to TYPE the contents of any file to the screen.
Syntax command | MORE [/E [/C] [/P] [/S] [/Tn] [+n]] MORE [/E [/C] [/P] [/S] [/Tn] [+n]] < Pathname MORE /E [/C] [/P] [/S] [/Tn] [+n] [Pathname[s]] Key command : Any executable command or batch file Pathname : The file to be displayed. [if more than one separate with spaces] /E : Enable extended features /E /C : Clear screen before displaying page /E /P : Expand FormFeed characters /E /S : Squeeze multiple blank lines into a single line /E /Tn : Expand tabs to n spaces [default 8] /E +n : Start displaying the first file at line n
You can create an environment variable called %MORE% and use this to supply any of the above switches.
More will convert any TAB characters to spaces in the output, by default 8 spaces.
If the output of MORE is redirected to a file [MORE demo.txt > output.txt] it will not prompt for the next page, unless the file contains more than 65,536 lines at which point it will prompt for each additional line.
When the output is redirected, this will also redirect/hide the --More [17%] -- prompts.
If extended features are enabled, [/E] the following keystrokes can be used at the -- More -- prompt:
Display next page Display next line Q Quit P n Display next n lines S n Skip next n lines F Display next file = Show line number ? Show help line
In PowerShell use | Out-Host -Paging in preference to MORE, it will start to yield results immediately through the PowerShell pipeline, without waiting first to collect all the incoming data.
Examples
Convert a Unix text file [LF line endings] to Windows text
file [CR/LF]
TYPE UnixFile.txt | MORE /E /P > WindowsFile.txt
“less is more” ~ Ludwig Mies van der Rohe
Related commands:
TYPE - display files.ECHO - display variables.
Equivalent bash command [Linux]: more / less - Display output one screen at a time.
Equivalent PowerShell: Out-Host -Paging
Copyright © 1999-2022 SS64.com
Some rights reserved