1

Let's say I am calling ls -la, which produces a very long output. Is there any key/command which lets my console scroll up to the first line of the output?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

3 Answers3

3

If the output is very long you could use the less command like below:

your_command_here | less

And then scroll all the way down by pressing keys like Enter, Space etc. For more see the less manpage.

You could even use more

you_command_here | more

more works like less but uses different key combinations to page through the text. For more see the more manpage.

Now you might remember that very old quote :

less is more

Thomas N
  • 744
sjsam
  • 1,594
  • 2
  • 14
  • 22
  • More important in my opinion is the fact that more doesn't let you go backward in the text, while less does. With more once you page down you can't go back. – Wildcard May 05 '16 at 20:12
  • Not true, actually. You can use the CTRL^B key sequence in more to go backwards in an output buffer, as long as you haven't scrolled past the end of the buffer, itself. – Thomas N May 05 '16 at 20:15
1

On Mac OS, iTerm version 3 beta can do this using a hotkey, if you enable shell integration: http://iterm2.com/features.html#shell-integration

egmont
  • 5,866
0

If you know your output size to scroll past one screenful, i.e., more than say 22 lines or so, it is upon you to plan against such incidence and set a method to buffer the output. This can be done simply setting the scroll-back buffer size of your terminal emulator, if it supports such thing and use the side bars to scroll up and down. Or better direct the stdout and stderr to file(s) for future inspection, either using redirection, > or >> or pipe the output to a tee file_name command.

Operating systems, at least the UNIX/Linux flavors that I deal with, don't provide a command to scroll up and down in the screen buffer, other than less and variants, which requires you to be prepared for such event, before you run your command. Sorry.

MelBurslan
  • 6,966