Ubuntu: Ubuntu server: How to pipe / scroll through search results of a certain command



Question:

This is perhaps a really simple thing to do, however, after looking on the internet I can not find the fast answer anywhere.

Suppose that I have this Ubuntu server running in a really small virtualbox.

When I use a command I sometimes can only see a small part of the results. What should I add after command to make me able to scroll through the results page by page?


Solution:1

You can use | more For example

ls -la | more  

It shows the top bit of the results and you can then use space or the down arrow to navigate downwards. Similarly, use it with any other command that produces too much for you to see at once.

For a bigger screen experience though, consider SSHing into the guest OS.


Solution:2

I'd pipe it through less

command | less  

Bit of a nicer feature set than more IMO.


Solution:3

What about sensible-pager from the sensible-utils package which is installed by default in Ubuntu:

command | sensible-pager


Solution:4

ANSWER: scrolling or "piping" through results can be achieved in some interesting ways.

  • more

Add | more after a command. This will enable you to scroll through results line by line by either hitting enter. When you reach the end of the list you return to the command-line. This can also be done by hitting space.

  • less or sensible-pager

Add | less after a command. With this you can search through results with the arrow keys, which enables you not only to go up or down, but also to go to the right and left. You explicitly need to leave to command-line with q. There is a whole bunch of other useful commands to add to this one.

  • most

Using most adds some more functionality to more and is used in the same way as less. I had to enable/install this first however. What I liked about this one is that you can see your progress in the results in the form of a percentage and current line/column.

My favorite would be less because it is the most easy to use.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »