Is there a way to paginate the output by piping it to some \'more\' command, which is available in linux\\unix shells?
Suggestion: Put the file into a temporary/disposable .txt file, then let the OS invoke your favorite editor, the one that is linked to the .txt extension.
Get-Process | Out-File temp.txt ; .\temp.txt
Note: each time you use this you will overwrite any pre-existent temp.txt file. Pick the file name wisely.
The above is just a basic idea.
Next step would be transforming this into "| more" using aliases or profile functions, etc.
HTH, Marcelo Finkielsztein
I had exactly this question (well I wanted less, not more) and found the answer of @richard-berg worked for me, being new to PowerShell (but not to Linux), I found the things missing from that answer (for me) were:
I first needed to go:
Find-Package pscx | Install-Package
which then prompted for "installing nuget package". I did this but then had to use the -AllowClobber
parameter on Install-Package
.
then in order to use less, I had to:
Set-ExecutionPolicy RemoteSigned
which all worked :-)
dir -rec | more
is bad advice.
It will cause powershell to evaluate the entire command prior to outputting it to the screen, something that is not needed for something like output paginating
In some extreme cases, it could cause the system to crash (e.g. dir 'C:\' | more
)
On the other hand, using out-host -paging
will output information to the screen as it is available.
Yes there is:
some-cmdlet | out-host -paging
cat C:\Temp\test.txt
cat is an alias for Get-Content - with larger files you will get the -- More -- output at the bottom of the terminal
You can also you can add -wait
cat C:\Temp\test.txt -wait
-wait is like using tail but it actually is rerunning the command just refreshing the output
cat C:\Temp\test.txt | oh –Paging
oh = Out-Host
more
isn't used to limit output, it's used to paginate output and make it easier to read in a terminal, if anything.
Are you talking about using head
and tail
? EggHeadCafe has an example of:
type my.txt | select-object -first 10
type my.txt | select-object -last 10
to emulate head
and tail
.