Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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).

share|improve this question
    
In which terminal? And do you have some example code? –  l0b0 Aug 13 at 12:54
    
Terminal that comes with Ubuntu distribution. My one is Ubuntu 12.04. –  rony Aug 13 at 14:12

5 Answers 5

up vote 4 down vote accepted

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.

share|improve this answer
2  
More of it, you can store the result in a text file like this: ls -l > result.txt. –  Pyrophorus Aug 13 at 13:07

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.

share|improve this answer

Even though the pipe solution (with more, less and tee) would be cleaner, you can also have your terminal keep more lines of output in its window (so that you can scroll up to it).

In Ubuntu 12.04, the usual terminal is gnome-terminal. Open one, and get to the preferences window (Edit > Preferences). In the Scrolling tab, you'll see a scrollback value, which should be set at 512 lines by default. This value represents the number of lines the terminal will keep available for you to scroll up to. You can increase this value, or check the Unlimited box.

Also remember that the more lines you have your terminal keep, the more memory it takes to do so.

share|improve this answer

1) You can use more or less with pipe

L10@Leo10:~$ command | more
L10@Leo10:~$ command | less

or else

2) You can redirect the command output to another file using >

L10@Leo10:~$ command > output

after execution of above, you can use any text editors to view the output file.

share|improve this answer

In "clean cases" (there's no term manipulation like what curses & do) you can also try if Shift-PgUp does anything. This will allow scrolling to some amount, usually a hundred lines or so. To cover more ground, use the methods others have pointed out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.