4

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

2
  • In which terminal? And do you have some example code? – l0b0 Aug 13 '14 at 12:54
  • Terminal that comes with Ubuntu distribution. My one is Ubuntu 12.04. – Kawsar Ahmed Aug 13 '14 at 14:12
5

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.

1
  • 2
    More of it, you can store the result in a text file like this: ls -l > result.txt. – Pyrophorus Aug 13 '14 at 13:07
4

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.

3

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.

2

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.

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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