How do i scroll in bash using keyboard?

Karl Auer kauer at biplane.com.au
Wed Dec 7 04:16:23 UTC 2011


On Tue, 2011-12-06 at 22:36 -0500, Sushil Mantri wrote:
> I have been a little bugged by this. I want to scroll up through the
> output of last executed command. I dont want to do 'less' or using
> <shift> + pageup.

Maybe you should tell us how you imagine it working. If you don't put
the output somewhere where you can read it, then your only option is the
scroll-back buffer of the terminal window.

For console terminals (i.e., if you are not using a graphical user
interface) you will probably not be able to use a mouse to scroll up,
and the shit-pgup method is about all you have. If you are using a
terminal window in a graphical user interface, then you should be able
to use the scroll wheel (of the thumb in a scroll bar) to scroll up and
down in the output of past commands. Depending on the terminal windows
software you are using you should be able to adjust the size of the
scroll-back buffer to a size that suits you. I generally set it to a
very big number.

There are a few options for storing the output from commands. Obviously
these may be less useful if the output is not text!

The "script" will put an entire session and every keystroke into a file
for later perusal:

   script
   command
   command
   command...
   exit

Or just redirect the output from a command into a file and look at it
when the command has finished ("2>&1" redirects error messages as well):

   command > file.txt 2>&1

Or you can use "tee" to redirect output into a file AND get it into
less:

   command | tee file.txt | less

Or even into multiple files:

   command | tee file1.txt | tee file2.txt | file3.txt > file4.txt

Or you can watch the output from something as it happens using tail - in
another window, or the same window if the command is running in the
background:

   command > file.txt 2>&1 &
   tail -f file.txt

Note: Command syntax off the top of my head - apply with caution :-)

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)                   +61-2-64957160 (h)
http://www.biplane.com.au/kauer/                   +61-428-957160 (mob)

GPG fingerprint: AE1D 4868 6420 AD9A A698 5251 1699 7B78 4EEE 6017
Old fingerprint: DA41 51B1 1481 16E1 F7E2 B2E9 3007 14ED 5736 F687

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20111207/b8951ce0/attachment.pgp>


More information about the ubuntu-users mailing list