How to get the terminal text those are overflowed during command execution?

Some commands have very large output texts in terminal. Sometimes some lines of texts goes out of the terminal during command execution. How to get that texts?

Update: I mean the terminal that comes with Ubuntu(12.04).


Solution 1:

When typing your command pipe it into "less" this allows you to scroll with the up/down arrows for example: ls -l|less Assuming you are talking about the standard bash terminal that is, which you probably are.

Solution 2:

Also worth mentioning, you can use tee to send the output both to a file and to STDOUT:

$ ls -al 2>&1 | tee currDir.txt

This will list the files in the current directory, while also writing them to currDir.txt. Note that the addition of 2>&1 will also allow this to capture anything sent to STDERR.