Mika H.
Mika H.

Reputation: 4329

Bash overfill terminal

I'm using Bash on Ubuntu, and sometimes when I run a command, the output overfills the terminal, even when I scroll up to the top. How can I access the part of the output that's hidden because of the overfill?

Upvotes: 2

Views: 182

Answers (5)

sampson-chen
sampson-chen

Reputation: 47267

You can try any of the following (Using the ls command as an example for where the commands would go):

Option A: Redirect the output to a file with > and then examine the file later with less or a text editor like vim or gedit.

$ ls > outfile
$ less outfile
$ vim outfile
$ gedit outfile
$ emacs outfile

To write the command's output to both stdout and stderr to your outfile, add a 2>&1 at the end, like so:

$ ls > outfile 2>&1

Option B: pipe the output of your command directly to less

$ ls | less

Note: if you view the output with less with either of the above options, use:

  • Ctrl+F to go down a page,
  • Ctrl+B to go up a page ,
  • Ctrl+D for down 1/2 a page,
  • Ctrl+U for up 1/2 a page
  • Arrow keys to move up / down line by line.
  • Press q to exit from less anytime.

Upvotes: 3

Arun
Arun

Reputation: 582

You can try Redirecting the output to a text file .

command > file

Upvotes: 0

paxdiablo
paxdiablo

Reputation: 881463

That's actually not bash doing that, it's the terminal program.

You have a couple of options. Perhaps the easiest is just piping your command through less, which allows you to scroll back and forth:

command_with_much_output | less

Secondly, you can configure your terminal program. Assuming you're using the default one, you can open up the Edit menu and select Profile preferences:

enter image description here

Then choose the Scrolling tab and you can change the scrollback buffer size:

enter image description here

Upvotes: 1

Diego Torres Milano
Diego Torres Milano

Reputation: 69208

Or you can increase the number of lines kept to scrollback in profile's properties (assuming you are using gnome-terminal).

Upvotes: 0

Gilles Quénot
Gilles Quénot

Reputation: 185126

You can pipe the output to less :

command | less

Upvotes: 1

Related Questions