9

In terminal a command has a too long output. But when I scroll back I see it is truncated and only the last part is shown. In Gnome-Terminal and Konsole I have this problem. In xterm there's not such problem but I cannot copy the output in xterm.

How can I get the complete output?

1

6 Answers 6

11

You could send the output to a file: command > file.txt (where command is the command you want to run and file.txt is the file you want to save it to) and then view it with gedit file.txt.

8

Use xclip

cat long.output | xclip -sel clip

If not installed you can do

sudo apt-get install xclip
1
  • This one is my personal favorite for GUI terminals. With TTY it won't work, unfortunately, only redirection to a file will help there Commented Aug 26, 2016 at 11:06
5

I know in the xfce4-terminal there is a option to increase the number of lines shown:

enter image description here

For ubuntu Terminal enter image description here

Aside from that there is what @Zelda64fan said.

1
  • +1 Pipe and tee are not optimal as dont work on few cases like take in a HROOT 3NVIORTNM3NT Commented Jun 1, 2013 at 5:35
5

If you don't need the entire output, you could pipe it through less: command | less. This would also save the bother of having to delete the file once you've reviewed the output.

1
  • 1
    less output is pretty hard to copy.
    – Sparhawk
    Commented Mar 11, 2014 at 6:41
2

In xterm, autocopy on select should be the default. Try triple-clicking then use a middle mouse button (or emulated third button) to paste.

The same should work with other terminals, but you need to manually copy and paste.

There a many, many ways to do this. I like using script in some cases. Type 'script' from a command line to start it before you launch a command from the command line, then hit Ctrl-D to stop. If you don't specify a capture filename, 'typescript' is the default. Everything printed to the screen should be captured in the file.

2

Save console output into a file:

  1. tee command

tee command - read from standard input and write to standard output and files.

It automatically creates file and save, all the output of cmd ps -ax into a file named as processes_info in the same folder from where the cmd has run.

user@admin:~$ ps -ax | tee processes_info
  1. script command

script command - make typescript of terminal session.

user@admin:~$ script my_console_output.txt

This creates a file named as my_console_output.txt and will open a subshell and records all information through this session. After this, script get started and whatever the console output, it will get stored in the file my_console_output.txt; unless and until the script ends when the forked shell exits. (e.g., when the user types exit or when CTRLD is typed.)

user@admin:~$ script -c "ps ax" processes_info.txt
  • it starts the script;

  • creates the file processes_info.txt;

  • stores the console output into the file;

  • end (close) the script.

    Other example:

     script -c 'echo "Hello, World!"' hello.txt
    
1
  • script -c "rails runner -e development lib/scripts/my_script.rb" report.txt helped me to capture a Rails runner script's very-very long output easily to a file. I tried using redirecting to a file but it got written only at the end of script. That didn't helped me because I had few interactive commands in my script. Then I used just script on my and then ran the rails runner in script session but it didn't wrote everything. Then I found this script -c "runner command here" output_file and it saved all the output as was desired. This was on Ubuntu 14.04 LTS Commented Apr 20, 2018 at 15:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .