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?
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
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
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
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
stderr to file(s) for future inspection, either using redirection,
>> 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.